Tutorial: Introduction to GDAL
Requisitos de finalización
4. Convert GIS formats
4.2. Convert vector formats
GDAL allows conversions between vector formats using the ogr2ogr command.
Here's a list of supported vector formats.
The general syntax is:
ogr2ogr -f <"Format"> <output> <input>
The "Format" is the short name in the vector drivers table and needs to be given in double quotes.
We're going to convert
gem_2011_gn1.shp
to a Google KML file that can be opened in Google Earth.1. Execute the following command:
ogr2ogr -f "KML" gem.kml gem_2011_gn1.shp
Ignore the warnings. They're related to formats and characters that are not supported.
Here you can find all options of the ogr2ogr command. Note that you can also reproject and convert at the same time by using
-t_srs
. There are many other things you can do, but we don't cover in this basic tutorial.2. Open the file in Google Earth to check the result.