Geography Reference
In-Depth Information
• The data is in the wrong coordinate system or datum.
• You want to create a subset of the data based on a bounding box.
• You want to create a subset of the data based on an attribute
query.
• You want to load data into PostgreSQL/PostGIS.
These all sound like good reasons for doing a conversion. Let's look at
a few simple examples to get you started with ogr2ogr .
Format Conversion
First let's convert a vector layer from one format to another. In the
simplest case, we specify the format we want to convert to, the source
layer, and the destination:
$ ogr2ogr -f GML cities.gml cities.shp
$ ogrinfo cities.gml
Had to open data source read-only.
INFO: Open of `cities.gml'
using driver `GML' successful.
1: cities
We just converted the cities.shp shapefile to GML. 3 Notice there was no
output or confirmation from ogr2ogr , but the file was created and con-
tains all features in the cities layer in GML. Going the other direction is
just as easy:
$ ogr2ogr -f "ESRI Shapefile" cities_from_gml.shp cities.gml
$ ogrinfo cities_from_gml.shp
INFO: Open of `cities_from_gml.shp'
using driver `ESRI Shapefile' successful.
1: cities_from_gml (Point)
Notice that we specify the format we are converting to using the -f
switch. Remember you can get a list of supported formats passing the
--formats switch to ogr2ogr . If the format name contains spaces, you'll
have to quote it as we did for the ESRI shapefile conversion.
Data Loading
We can use ogr2ogr to load data into a PostGIS-enabled PostgreSQL
database. If you are loading just shapefiles, you could use the shp2pgsql
utility that comes with PostGIS. Otherwise, you will find ogr2ogr handy
for loading other data types.
Geographic Markup Language—see http://www.opengeospatial.org/standards/gml .
3.
 
 
Search WWH ::




Custom Search