Professional Documents
Culture Documents
geodatabase
30
One raster format to another raster format: if we use a GIS for pre- or postprocessing of data
for a tool or a model, the data needs to be read or produced in the format supported by the
tool or the model. Thanks to the Geospatial Data Abstraction Library (GDAL) many
conversions are supported in commercial and open source GIS applications
One vector format to another vector format: similar to raster, but here often the OGR simple
features library is used to translate from one to another format.
From raster to vector: this is useful when analysis is done using vector geoprocessing
algorithms. This is also useful for presenting data to decision makers who often prefer data in
vector format.
From vector to raster: in order to perform map algebra or other raster analysis, vector data
can be converted to raster data.
Conversion to and from geodatabases: instead of using files, GIS data can also be organized
in geodatabases.
In this exercise we will download OpenStreetMap data for your area of interest. OpenStreetMap
(OSM) is a collaborative project to create a free editable map of the world
(http://openstreetmap.org). Next we will import the data into a geodatabase. After doing some
queries, the resulting data will be saved in shapefiles. Some of the shapefiles will be converted to
KML to visualize in Google Earth and other shapefiles will be converted to raster in order to apply
map algebra.
4. A popup screen shows up where you have to indicate the CRS of the GeoCode layer (your
search will result in a layer added to the map canvas). You can choose EPSG:4326
32
2. Zoom in to your area of interest. You can move the GeoCode layer to the top, so
OpenStreetMap is in the background.
Now look at the map. What kind of features can you see? Is the map vector or raster?
33
3. In the dialogue choose From map canvas for the extent and browse to select an output file
name (e.g. Kampala.osm). In case internet does not work, this file has been provided so
you can continue offline with the exercise.
4. Click okay and wait until the data has been downloaded. If the popup with the message
Download has been successful appears, click OK and Close to go back to return to the map
canvas. Note that sometimes with a poor internet connection the download can be
incomplete, but no error message is displayed. This results in an empty attribute table. If this
occurs, try to download the file again or use the file from the Open CourseWare website.
5. The file you have downloaded is a .osm file. This is an XML format that is supported by OGR.
Therefore, you can open it easily in QGIS. Click the Add vector layer button
and browse
to the .osm file. Click Open.
6. A popup window shows up and asks you to select one or more layers from the file. Click
Select All and OK.
34
2. Inspect the attribute table. You can see that it contains for example street names and road
types. Now were going to select the primary roads from the attribute table. Click (Select
features using an expression) from the toolbar on top of the attribute table.
3. In the dialogue that opens, we can build the expression for the selection of primary roads.
a. First click on the + sign before Fields and Values
b. Double click on highway. You can see that highway has been inserted under
expression.
c. On the lower right, under values, you can click all unique load all unique values.
d. Click on the = button
e. Double click on primary. Now the expression should look like this:
f.
35
4. In the title of the attribute table window you can see the number of selected features out of
the total. On the lower left you can click on Show selected features.
2. In the dialogue choose ESRI Shapefile as the output format. Save the file as
PrimaryRoads.shp. Here you can also change the CRS of the output file. Click on the
select CRS button, choose EPSG:21096 and click OK. This is the projection used in Uganda,
north of the equator (UTM Zone 36N/Arc 1960).
36
3. Click Save only selected features (if we dont check the box we can convert the entire lines
layer to another OGR format), check the box to Add saved file to map and click OK.
4. Repeat the procedure to select from the points layer (points any) the manmade towers
(man-made = tower) and save the results to Towers.shp
37
5. Repeat the procedure to select from the polygon layer (multipolygons any) the
commercial buildings (buildings = commercial) and save the results to
Commercial.shp
3. Now we can type the expression directly at the top of the attribute table: Value = 1. Click
Update All. Now the Value column will be filled with ones.
4. Click
to toggle back and save the edits.
5. From the main menu choose Raster Conversion Rasterize (Vector to Raster)
38
6. Fill in the dialogue as below and click OK, OK, OK and Close. This results in a Boolean raster of
3000 x 3000 pixels with value 1 for the commercial areas.
2. Browse to the folder where you want to save it and give it a name, e.g. Kampala.sqlite.
A popup window informs us that the database has been created.
39
3. Now we have to fill the database. In the main menu choose: Database DB Manager DB
Manager.
4. A new window appears where we can control the databases in QGIS. Click on the + sign
before SpatiaLite to see the databases. Then select Kampala.sqlite.
5. The database is empty and we need to import the layers. Click on the Import layer/file
button
.
6. Choose the layer to input. Start with the Tower points. Click Update options to pre-fill some
of the form option. Specify the source SRID and target SRID as 21096. Enable the check box
to create a spatial index. Click OK to perform the import.
21096
21096
7. Click OK when the popup shows up that the import was successful.
8. Click the refresh button
40
9. Repeat the same steps for PrimaryRoads and Commercial. Note that we cannot import
raster data. Finally the DB Manager should have the points, lines and polygons.
Select all the layers and click Add. The layers will be loaded into the map canvas.
41