Lake Tanganyika Project: Zambia National Site Characterisation and Catchment Management Design Workshop

 

GIS training module – lesson 5

Thomas Gumbricht, ICRAF

 
       

     

 

 

Lake Tanganyika Regional Integrated Management Project

A United Nations Development Programme (UNDP)   Global Environmental Facility (GEF) project covering the Lake Tanganyika riparian countries, Burundi, the Democratic Republic of Congo, Tanzania and Zambia.

Training module created by Thomas Gumbricht, www.mapjourney.com

Last updated: October, 2010

LESSON 3 – SELECTING FEATURES, LABELING AND DESIGNING MAPS

  1. Lesson overview 

In this lesson you will learn how to select features in a layer and create a new vector layer from the selection; and how to label and design maps using DIVA-GIS.

  1. Create new project and set options 
Start DIVA-GIS and open a new project by clicking the New Project button,
, or via the menu: Project  - New. Save the new project (e.g. under the my_diva folder calling it lesson3).
 
    1. Set DIVA-GIS defaults and options 

In this lesson you will work with the database and create some new data layers and image files. In DIVA-GIS you can set different options for how to select data in the Data View. To get to the various options go via the menu: Tools – Options. Skip the Climate tab, and click the Layer tab.

 

In this lesson you are going to create new layers and design maps, and export them as files. Hence if you are working using a CD you must uncheck the option for Save relative paths in the project file, otherwise keep it checked. Also if you work with the dataset on a CD you must create a project folder on your local hard drive for saving the files you generate in this lesson. There are also other options to set, including the color of selected features, and the way to select features interactively). Once you are into this lesson you might want to return to the Options menu and make some changes in your settings.

  1. Select features 
Use the Add Layer tool,
, or go via the menu: Layer – Add Layer, navigate to the folder \data_spatial\laketan\political\vector and add the layer country_index. Open the Properties window for this layer, either by double clicking the layer in the Legend, via the menu: Layer – Properties, or click the Properties tool,
. To start with you only need to symbolize the countries using a Unique value, so make sure the Unique tab is selected, as shown below (left). Double click the rectangular symbol icon to open the Symbol window. And set the Style to Solid Fill. Then also select a Color and a Border Color. If you need to repeat symbolization, you can go back to lesson 2.
 
 
 

You should now have a DIVA-GIS project window that shows the countries of Lake Tanganyika. In the example below the Label was changed (in the Properties window – shown above).

 
The project to which this lesson belongs covers five countries in Lake Tanganyika: Burkina Faso, Mali, Mauritania, Niger and Senegal. To locate these countries, you need to select these districts by a Query – that is, ask the database to find the countries for you. Query or selection is a very important function in GIS, and one of the key differences between a GIS and an ordinary map. Open the Select (Query) window in DIVA-GIS by clicking the Query tool,
, or via the menu: Layer – Select Records.
 
Make sure the tab for Select by values is on top, click the drop down menu for Variable and select CNTRY_NAME. You will get a list with all countries in the Sahel. You have to use the scroll bar to the right to see them all. Click the Clear All button,
, and scroll down and check the records for Burundi, DRC (Zaire), Rwanda, Tanzania and Zambia (you can also choose just one or two of them).
 
 
Click the Apply button,
, and close the Select window. Your Data View should now show the districts that you selected, in the color that was set in the Option window at the beginning of this lesson (you can now change the option for Color of selected features if you want, but the tutorial will use yellow).
 
To clear the selection, click the Clear Selection tool,
, or go via the menu: Layer – Clear Selection.
 
You can also select features directly from the Data View, with the Select Feature tool,
, or via the menu: Layer – Select Feature. The Select Feature will appear pressed down,
, and the cursor changes to a crosshair. If you click on a feature it will become selected and turn yellow. The way the selection tool works can also be set in the options menu (see above).
 
When you selected the features, the Zoom to Selected tool,
, became active. If you click on it, the Data View will zoom to show the selected features. In the example below, an overview map was added, simply by clicking F7 (see lesson 1 to repeat how to make an overview map). To remove the overview map, simply press F7 again.
 
 

To select more than one feature, for adjacent features (like Tanzania and Burundi) you can use the mouse to draw a rectangle (or circle or polygon – you can set this in the Option window – see above in this lesson), and all features falling inside the rectangle will be selected. To select features that are not adjacent, you first select one, then hold down the Ctrl + Shift keys and click (or draw a rectangle/polygon etc) around the features you want to add to the selection (this function is a bit unstable in DIVA-GIS, but you can try).

    1. Filter features 
There is a second option to select and at the same time filter the Data view appearance in DIVA-GIS – the Filter tool,
, also available from the menu: Layer – Filter. If you use this option, the Data view will only show the features you select (single or multiple feature(s) can be selected).
 
    1. Save as new shapefile 

Select the country you want to work with (Tanzania will be used in the this tutorial). In DIVA-GIS you now have the option to create a new shape file containing only the selected features. Click the Convert To Shapefile tool, , or go via the menu: Data – Selection to New Shapefile. In the Save As window that pops up navigate to your my diva directory, give the new layer a logical name and save it as a shapefile (*.shp).

 

The new shape layer will be automatically added to the DIVA-GIS Data View. It will be symbolized as a polygon with no fill and a black border (DIVA-GIS default).

  1. Symbolizing 

In the attribute table for countries there is both nominal and ratio data. In lesson 2 you learned that nominal data can be symbolized using either a single value (one color for all features), or using Unique values. Make the original country (country_index) – if you changed the label above the name in the Legend of the layer also changed) map the active theme, and open the Properties window. Select the tab for Unique, set the Field for symbolization to CNTRY_NAME in the drop down menu. Click the Reset Legend button. All countries will get a default color, which is unique for each country (unless you checked the checkbox for Use color of single tab, in which case all countries will have the same color, but then just uncheck and press Reset legend again). You can change the color for each feature by clicking the small symbol icon (rectangle for polygon themes).

 
 

You can also exclude any feature by unchecking the checkbox for that feature in the Properties window. First just look at the alternative of having all districts included, with Unique values for the Symbolization. Click Apply and you should get a Data View similar to the one below.

 

The symbolization is difficult to read, there are too many entries, and you can hardly identify the countries from the legend. One alternative is to return to a single symbolization for all the countries, and then symbolize the layer with the selected country/countries separately and put the selected country/countries on top. Try that out, and you should get a map similar to the one below (with your choice of colors).

 
  1. Labeling 

A second, and complementary alternative to symbolization is to put labels directly in the map. Make the theme with all the countries the active theme, and go via the menu: Layer – Add Labels.

 

In the Add Labels window select the Field CNTRY_NAME for labeling in the drop down menu, you can choose if the label should have a colored background, and what color that background should have.

 
Click the Set font button,
, in the Add Labels menu to select font and the font style etc.
 
 

Click OK in the Font window, and OK in the Add Labels window, and your map will get labels. The name of each country is now easy to see and read. To improve the contrast between the country symbolization and the text, the fill color for the countries can be changed in the Properties window.

 

Try to symbolize the country map using Unique values (check the Use color of single tab before clicking Reset legend) in the Properties window, as shown below.

 
 

When you click Apply the symbolization of the polygons work fine, but the labeling will disappear, as shown below.

 

If you put labels on a map symbolized with Unique values, the uniqueness will disappear. This is a small bug in DIVA-GIS, but there is a way to get around. You simply add a second copy of the layer country_index, which you can do by just copying a layer in the Legend and then paste it from the menu: Data – Copy Layer / Paste Layer.  Put the second copy of the layer on top in the Legend, and use this copy of the country layer for labeling. The labels will then end up on top of the map, and the symbolization of the underlying layers can be done without consideration of labeling. In the example below the legend of the labeling theme (country_index) was hidden. You can hide the legends from the menu: Layer – Hide/Show Legend, or by pointing at the layer in the legend and clicking the right mouse button and selecting Hide/Show Legend.

 
  1. Database query 
DIVA-GIS contains a more advanced query function for searching data. Make sure the layer with all the countries (country_index.shp – labeled to Lake Tanganyika Countries above) is the active theme and open the Query window (e.g. click the Query tool,
,or via the menu: Layer – Select). Click the Select by query tab to get to the more advanced query option (see illustration below). Now you can do searches using separate fields, or combining several fields. Start with querying the database for all countries with GLASOD_Z value larger than 0.3. In the drop down menu for Field select GLASOD_Z. In the drop down menu for Critera select > and then enter the Value 0.5. When you have completed the Condition, the ADD  => button,
, becomes highlighted. Press it to transfer the query condition to the main area of the Select window, as shown below.
 
 

Click Apply to invoke the query, and all countries fulfilling the conditions will be selected (turn yellow if you did not change the color for selected features).

You can now add more query options, first double click one of the alternatives for Operators, AND in the example below.

 
The main query will be updated with the selected operator. Now you can add a second condition, for instance only searching for landlocked countries, as in the example below. Remember you must click the Add => button,
, to transfer the added query condition to the compiled query seen in the main area.
 
 

If you click Apply, the selection will be restricted to countries fulfilling both conditions (because you used the AND operator). If you instead had used the OR operator, countries fulfilling any of the two conditions would have been selected. The result of the query (GLASOD_Z > 0.3) AND (LANDLOCKED = 'Y' ) is shown below.

 

If you permanently want to save the result of your query you can do that by using the Convert To Shapefile tool, , that you used before in this lesson. More advanced GIS software have more query options, but AND and OR are by far the most commonly used operators.

Designing a map

When you are satisfied with the country map of West Africa, click the Design tab in the lower right corner of the Project window (you can also press F10, or use the menu: Map – Design View). An empty Design View will open. The tools at the top of the Design View are used for adding map elements to the Design view. Most are grey; to get them active you must start by adding the Data View. Click the Symbol for Add Map,
, unless it is not already chosen (activated by default when a new design is created). You can decide where in the Design View you want to have the map (or rather, its upper left corner), by entering Location X and Y values followed by clicking the OK button,
. You can also tell DIVA-GIS to Cut white space (areas in the Data View where that are not covered by a layer).
 
 
With the map element in the design view you can just click in the Design View to add other Map elements, or another instance of the Data View. The editing capacity of the Design View is not very developed, and once a map component has been added you can not move it, but either click the Undo button,
, before you add another component, or simply start all over again by clicking the Clear all tool,
. When you added the map to the Design View, the other tool buttons for adding map components became active (colored). Add the legend by clicking the Legend button,
. Clicking any of the tools for adding a map components changes the menu to the left to reflect properties you can set for that particular map component. With the map element added, there is a better way to position forthcoming elements: by clicking directly in the Design View. The element will then be positioned with its upper left corner at the click-point. When adding the Legend element below, the legend entry for the copy of country_index, used for labeling the map, was unchecked, and it is not shown in the Design View, and the legend for the layer with all the countries was set to single symbol.
 
 
Then add a scale element by clicking the Scale tool,
. The scale bar options appear in the menu to the left, with distance units set to the Distance Measurement Units set for your project (see lesson 1).
 
Add a North Arrow by clicking the North Arrow button,
. You can also include an overview map, by clicking the Overview Map button,
, but in the map we are now designing the Map component and the Overview map are then same, so no overview map is needed. Finally you can add text to your design by clicking the Text button,
. For the text component you can set the font and its characteristics by clicking the Font tool,
.
 
 
The next time you add a map component to the Design View, it will get the font that you have set. In this way you can use different fonts for your different components (including different text entries). By choosing a color from the Color tool,
, you can set the color also of the Scale bar the North Arrow, and outlines around the Legend and Overview Map components. The Color tool overrides any setting of font colors, and can be used to select a wider variety of font colors also for Text components.
 
When you have finished designing your map you can export it to the windows clipboard, print it, or create an image by clicking one of the Export tools,
. The image below was simply created by clicking the Copy to Clipboard button, then clicking in the word document used for making this lesson and pressing ctrl-v.
 
 

Try in on your own – design land degradation map over West Africa

The map below shows the GLASOD country statistical land degradation index (attribute GLASOD_Z in the attribute table) designed with DIVA-GIS. The map is just an illustration, and not an authority on land degradation. Try to use DIVA-GIS to make a map like the one below by using what you learnt in this lesson.

 

The last task in this lesson is to label and design a map in DIVA_GIS showing the original GLASOD classification, illustrated below.