Introduction to GDAL

This tutorial will introduce you to the GDAL command line tools.

4. Convert GIS formats

4.3. Spatial queries of vector data

For our map of Delft we want to do the following GIS analysis:

  • Select the community of Delft from the community map and save it into a new shapefile;
  • Intersect the community boundaries of Delft with the road map of the Netherlands.
We can use a spatial query to select a feature from a vector map.

1. What is the attribute in the community map containing the names of the communities? You can use either ogrinfo or QGIS to answer this question.

2. Execute the following command:
ogr2ogr -f "ESRI Shapefile" -where GM_NAAM='Delft' -a_srs EPSG:28992 delft.shp gem_2011_gn1.shp

This will save the feature with GM_NAAM Delft to a new file called delft.shp. The argument -a_srs EPSG:28992 is used to assign the Amersfoort/RD New projection to the output file. The argument -f defines the output format.

3. Now open in QGIS the reprojected DEM (dem_rd.tif), the reprojected road map (roadsreprojected.shp) and the community of Delft (delft.shp).

Result GDAL