8.3. OpenEV Basics

 < Day Day Up > 

OpenEV has a variety of simple and complex tools. Many of the advanced tools have been designed with raster data in mind, but the basic toolsets and controls include many of the features needed to do quick visualization of both raster and vector data.

8.3.1. Zooming

One the first things you will want to do is zoom in to certain portions of your map. There are a couple ways to do this. The first is to use the plus and minus buttons on the toolbar of the view. The icons are a magnifying glass with a + and - symbol inside them. Clicking + zooms into the center of the screen, and clicking - zooms out from the center of the screen.

The more efficient way is to use the Zoom tool, which allows you to drag a rectangle on the screen and zoom in to that portion of the map. To enable the zoom tool, select the Edit Toolbar from the Edit menu, then choose Zoom from the list, as shown in Figure 8-6.

Figure 8-6. Activating the zoom tool


Now you can return to the view and click and hold the left mouse button to zoom in. You can also drag a rectangle around a portion of the screen and have it zoom in directly to that location. To do this, click and hold the left mouse button, then drag the mouse to another location. Watch as the rectangular zoom box appears, as in Figure 8-7. When the box covers the area you want, let go of the mouse button.

Zooming out can be done a few ways as well. As mentioned earlier, you can use the zoom-out magnifying glass button, but you can also hold the right mouse button down and slowly zoom out. Another method to use, if appropriate, is the Fit All Layers button on the main view tool bar. This button is a rectangle with four internal arrows pointing toward the corners of the rectangle, as shown in Figure 8-8. Clicking this button zooms out so far that all the data in all the layers can be seen.

If you use this tool and find that you can no longer see your data, it is probably because one or more layers are in a different map projection. If you know the layer, remove it from the Layers window, and try Fit All Layers again. There is no tool to return you to the previous viewing extent.


Figure 8-7. Select an area with the zoom in tool


Figure 8-8. The OpenEV toolbar, pointing out the Fit All Layers button


8.3.2. Panning

Many desktop mapping programs have a feature called panning. This is a way of sliding or moving the map around so you can look at different portions without having to zoom out and then back in again. The scrollbars in the view play this role. If there is map data beyond the sides of a view, you can slide the scrollbar or click on either arrow at the ends of the scrollbars. This moves you to the area you are looking for without changing the scale or size of the map features.

8.3.3. Color Theming

You probably don't always want to show all the features of a map layer using the same color. For example, the roads layer includes two different classes of roads. You may want to show each class in a different color, with a different road line thickness. Or you may not want to show one of the classes at all.

This road data includes an attribute that tells you what class each segment of line is. To use the values of this field to color the lines differently, you can use the Classify button on the tool bar, shown in Figure 8-9. It is a button with the letter C inside it.

Figure 8-9. OpenEV's classify button


Click on this button, but remember to have the layer you want to classify (e.g., Roads) selected in the Layers window. The Layer Classification window appears (see Figure 8-10) and makes a basic set of classes for you.

Figure 8-10. Classifying a layer using a feature attribute


For the road data it uses the LENGTH attribute by default because it is the first attribute. Switch the drop-down list in the top-right corner of the window to another field and see how it recreates the classification on the fly. Change this setting to the attribute ROAD_CLASS. This yields several values in a list, as shown in Figure 8-11.

Figure 8-11. Classifying by road class


The default method for classifying these values isn't appropriate because it uses a range of values. There are only two road classes: integer numbers 4 and 5. You can change the way the classifier works by selecting the reclassify button. Change the Type to Discrete Values and press OK. This gives each distinct value in the ROAD_CLASS field a different color, as shown in Figure 8-12.

Figure 8-12. Classifying roads into two road classes


Notice how there appear to be some primary roads (class 4) and secondary roads (class 5). You can change the colors for each class until you are satisfied. Hit the Apply button to draw the roads using these colors, as shown in Figure 8-13. Remember that if one of the colors is black, it won't show against the black background in the view window.

Figure 8-13. Applying color-theming using the road class attribute


There are several other options available in the classifier. One that is handy is the default set of Color Ramps in the drop-down on the Layer Classification window, shown in Figure 8-14.

You can quickly classify, reclassify, and set various color themes. Just select an item from the Color Ramps dropdown list, and hit Apply. Don't like it? Change it, and apply again. If you only have a couple values in your classification, these color ramps won't be as valuable, but they are particularly useful for raster data. When you are happy with the results, press the OK button to close the classification window.

Figure 8-14. Selecting a color ramp to classify features


In some case the vector layers may not draw properly after applying a color ramp. The workaround is to remove the layer and then add it again.


8.3.4. Loading a Raster

Adding a raster layer can often be easier than adding vector themes, because common raster formats are usually a single file with colors already assigned. The raster used in this example is a land cover dataset that covers the earth, but for this example it's focused on Itasca County, Minnesota. You can download the image from this book's O'Reilly web site at http://www.oreilly.com/catalog/webmapping.

This is a GeoTiff image, also known as a TIFF file. The .tif extension is the common filename suffix. Add the image to the OpenEV view by selecting File Open and browsing your filesystem to find the landcover.tif file. Double-click on the filename or press the OK button. Notice that the layer is added to the list in the Layers window, but is currently not visible on the map (well come back to this point). It automatically becomes the topmost layer. Select the layer from the list and use the down arrow at the bottom of the layer window. This will move that layer to the bottom so that the vector data (airport points) will show on top of the other layer when it is ready.

If you right-click on the layer in the layer list, there are some options to select and change, just as with vector data, but the options are very different. The General tab is the only similarity. Some tabs are for information only; others will alter how the raster is displayed.

8.3.5. Reprojecting Data to Match Another Layer

Even if you press the Fit All Layers zoom button, you won't see the land cover layer because the workshop dataset and the land cover dataset aren't in the same map projection. This is a common problem when taking data designed for a county or region and using it in a global map.

In this case, the workshop datasets are in the UTM projection. The land cover raster isn't projected and uses geographic coordinates, specifically latitudes and longitudes measured in degree units. More information about map projections is available in Appendix A.

OpenEV doesn't itself have the ability to reproject data layers. The tools introduced in Chapters 3 and 7 can be used to reproject a layer so that OpenEV can display it the way you want.

This chapter discusses map projections but shows only one real-world example of their utility. For more in-depth explanations and examples of map projections, see Appendix A.


In this example, ogr2ogr (introduced in Chapter 2) is used to reproject or transform the coordinates of the airport data from one spatial reference system to another:

     > ogr2ogr shp_geo airports.shp airports -t_srs "+proj=latlong" -s_srs "+proj=utm +zone=15"

There are four parts to this command. The first section is the parameter that specifies the output dataset name. In this case, it creates a folder called shp_geo to put the translated files into.

The next section specifies what the input data is going to be. ogr2ogr reads in the airports.shp dataset and, specifically, the airports layer in that shapefile.

The next part starting with -t_srs specifies what target (or output) spatial reference system (t_srs) to put the data into. Without going into detail, the projection is set by +proj=, to output the data into latlong coordinates.

The final section -s_srs defines what the source spatial reference system (s_srs) is. Because the airports.shp file doesn't have projection information included in it, you have to know what it is and specify it here. This allows ogr2ogr to calculate what transformation to use. In this case, +proj=utm +zone=15, the projection is UTM, and the UTM zone is 15.

These are the most basic projection settings and will work for you, but you should be aware that to more accurately describe your data, you may need to specify more projection details such as datum, ellipsoid, or units.

When specifying projections you can use the EPSG code number as a shortcut. These are integer numbers. You can do so using the +init setting, not +proj. For example, you can specify:

     -s_srs "+init=EPSG:26915"

for the UTM, zone 15 projection and:

     -t_srs "+init=EPSG:4326"

for lat/long coordinate system.


Continue this conversion exercise for all the other workshop datasets (i.e., ctyrdln3.shp) so you can use them in your map. Just change the source and destination dataset/layer names in the ogr2ogr command example.

Add the newly created shp_geo/airports.shp file to the view. To quickly see their locations, remove the old UTM-based airports layer from the view, then click the Fit All Layers button to zoom out to the whole earth. Zoom in to the United States, and see where the airports fall. They are located around -93.54E, 47.53N degrees. You may need to resize or recolor the airport point symbols so that they are visible on top of the image, as in Figure 8-15. The locations are now shown to be on top of the land cover image, in northern Minnesota, because they are both in the same map projection. Figure 8-16 shows the map zoomed in to the area.

8.3.6. Creating a 3D View

OpenEV can render simple 3D perspectives of data. This is done using two input layers. One image shows the elevation surface this is often called a Digital Elevation Model or DEM where dark to light colors represent low to high elevations, respectively. The other input layer is the image you would like draped over the DEM. This can be thought of as a sheet being draped over a basketball, where the ball represents the elevation model.

Acquiring or creating these two layers can be tedious and frustrating. You need data colored a specific way to make it work. The images also need to have matching spatial reference systems so they overlap geographically. There are also several options which, if specified incorrectly, can produce inaccurate or unusable results.


8.3.6.1 Preparing the Digital Elevation Model

The first image you need is a DEM. If you don't have this kind of image, you can't create a useful 3D perspective of your data. If your target application is the United States, a lot of DEM datasets are available. They can often be used in OpenEV without any data conversion.

Figure 8-15. Land cover image with general location of airports shown by a black star


Here are some sites that have elevation datasets available:


GTOPO: Global digital elevation model

http://edcdaac.usgs.gov/gtopo30/gtopo30.html


SRTM: Global coverage from Shuttle Radar Topography Mission

http://srtm.csi.cgiar.org/Index.asp


USGS DEM: Digital elevation models for the United States

http://edcsgs9.cr.usgs.gov/glis/hyper/guide/1_dgr_demfig/states.html


U.S. National Geophysical Data Center: Various types of data

http://www.ngdc.noaa.gov/mgg/bathymetry/relief.html

The image used in this example is called hibbing-w and was downloaded in the USGS DEM data format from http://edcsgs9.cr.usgs.gov/glis/hyper/guide/1_dgr_demfig/states/MN.html.

Figure 8-16. Zoomed in to the airports with the land cover image shown in the background


OpenEV and GDAL-based applications can read this image format. Add the image to a normal OpenEV view, and you will see that the image is grayscale sometimes referred to as black and white (though that isn't technically correct). When you switch into 3D mode, black represents the lowest elevations in your model, and white represents the highest elevations.

The hibbing-w image is a good example of a smooth progression of shades from black to white, as shown in Figure 8-17 (in normal 2D mode). This is ideal. A DEM that has a very limited color gradient, with sharp contrasts, produces a chunky and unrealistic-looking surface. It would ultimately be useless unless you wanted an unnatural appearance.

Figure 8-17. The DEM image for part of Minnesota, U.S.A.


8.3.6.2 Preparing the drape image

The other image you need is called the drape image. It's overlaid or draped on top of the DEM. The DEM surface itself isn't visible except by seeing the shapes and contours of the drape image laying on it.

Any image can be draped on the DEM, but it's not as easy as it sounds. There are some strict requirements you need to follow to get meaningful results.

The drape and DEM image sizes or extents must match, or the coordinate systems must be identical and overlap each other. You can have a high-resolution DEM with a lower resolution drape image, but the drape image must fall on top of the DEM to be shown properly.

One way to ensure that your drape image is useful is to have OpenEV output snapshots of your DEM and drape image to new files. In this example, the drape and DEM images are created by turning on various layers and printing them into new TIFF images.

You start by loading OpenEV with the DEM image and some of the workshop data layers. Remember to use the data in lat/long coordinates described earlier so it matches the DEM projection.

Now, with all layers except the DEM turned off, zoom in to the image. To take a snapshot of this DEM, use the Print command under the File menu. In the Print window, set the following:

     Driver: TIFF     Device: FILE     File: <path to a local folder>/dem.tif     Output Type:Greyscale     Resolution: 1

Figure 8-18 shows how to put these values into the print window.

Figure 8-18. Printing the DEM map into an image file


When you press the Print button, OpenEV takes the contents of the View and outputs it to the new image file you specify. The same thing is done to create the drape image.

The main thing to remember when creating your drape image is not to move around in the view. Don't zoom in or out but keep looking at the same location that was used to print the DEM image. Turn on different layers: water, roads and the land cover image for example, as shown in Figure 8-19. Then go through the same print process as earlier, changing the File setting to call the file drape.tif instead of dem.tif. Be sure to switch Output Type to color if applicable.

Figure 8-19. Using the print window to output a drape image


8.3.6.3 Initiating the 3D view

You are now ready to combine the DEM and drape images to create a 3D perspective. Select New View from the File menu to create a new working space without closing View 1. Then, in that new view, select Open 3D from the File menu. This displays a new window (see Figure 8-20), prompting you to select two different images: the DEM in the upper selection box and the Drape image in the lower one. Find the images you created earlier, and enter them into the filename selection boxes. Leave the rest of the options with their default settings, and press OK.

Figure 8-20. Creating a 3D view


OpenEV then creates the default perspective of your 3D view as shown in Figure 8-21.

The background is black, and the color drape image is shown with dips and bumps conforming to the DEM underneath. You can now navigate your way through the image and also raise or flatten the DEM further.

8.3.6.4 Navigating the 3D view

The controls for navigating in the 3D view aren't always easy to use but are sufficient for getting a quick perspective of your data. Navigating the 3D view isn't very

Figure 8-21. The default 3D view of a model


intuitive if you are new to the concept. Keep in mind that OpenEV is tracking several things about your 3D model and your location. The view acts like a camera, which requires you to look through a viewfinder. The camera is always looking at the subject, in this case the 3D model, from a certain location in space. By default, the view camera is positioned higher than the model and not right over it. A specific part of the model is in the center of the view, and the camera is tilted to a certain angle.

As in the normal 2D view, you zoom in to the model by holding down the left mouse button. Where the cursor is pointing is irrelevant. It always zooms in to the center of the view.

Moving the mouse while holding down the left mouse button the pivots the camera both horizontally and vertically. This is where navigation can become a bit tricky. If you pause for a split second while pivoting your camera, OpenEV will start zooming again right away.

To drop the camera up and down or slide it left or right, hold down the control (CTRL) key while dragging with the left mouse button. Again, be aware that zooming will begin if you stop moving and continue to hold down the left mouse button.

There are some other keyboard controls that do the same tasks as the mouse commands. Page Up/Page Down zooms in/out. Pressing Shift while doing this makes it zoom faster. The keyboard arrow buttons move the camera up/down and left/right. The Home key returns you to the initial 3D view. This is especially useful if you get lost or are still learning to navigate.

It is possible to know the exact location of the camera and to change it manually by setting the camera coordinates. This is helpful if you want to recreate a scene at a later date. To do so, use the 3D Position options, found under the Edit menu. As seen in Figure 8-22, it lists the X,Y, and Z position of your camera as well as where the camera is looking on the model in the center of your view. These position values refer to pixel row and columns. You can change any of these values and the view will be updated. Simply change the value, and press Enter or Tab into the next field.

Every 3D model has a setting for a height or Z scaling factor. This is the amount that the DEM is stretched vertically, giving it the 3D appearance. Other applications and cartographic processes refer to this type of setting as vertical exaggeration. The default in OpenEV is 1.0 and is set in the Open 3D window before initiating your 3D view. If the setting is too low, your model will look flat; if too high, your model will look jagged or meaningless. This setting can be changed while viewing your 3D model using the plus + or minus - keys. Combining them with the Shift key allows you to rapidly increase or decrease the scaling factor. In Figure 8-22, the Z scaling factor is reduced to make the landscape look more realistic.

Figure 8-22. The 3D position window showing camera location and focus


     < Day Day Up > 


    Web Mapping
    Web Mapping Illustrated: Using Open Source GIS Toolkits
    ISBN: 0596008651
    EAN: 2147483647
    Year: 2005
    Pages: 138

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net