Tutorial: Introduction to GDAL
Requisitos de finalización
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. We can clip the
roadsreprojected.shp
vector so it only covers the municipality of Delft. We use the -clipsrc
argument.ogr2ogr -clipsrc delft.shp roadsdelft.shp
roadsreprojected.shp
4. Now open in QGIS the reprojected DEM (
dem_rd.tif
), the clipped road map (roadsdelft.shp
) and the community of Delft (delft.shp
).