O'Reilly logo

Python Geospatial Analysis Cookbook by Michael Diener

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Converting a Shapefile to a PostGIS table using ogr2ogr

The simplest way to transform data from one format to another is to directly use the ogr2ogr tool that comes with the installation of GDAL. This powerful tool can convert over 200 geospatial formats. In this solution, we will execute the ogr2ogr utility from within a Python script to perform generic vector data conversions. The Python code is, therefore, used to execute this command-line tool and pass around variables so that you can create your own scripts for data imports or exports.

Using this tool is also recommended if you are not really interested in coding too much and simply want to get the job done to move your data. A pure Python solution is, of course, possible, but it's definitely ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required