GDAL and OGR Python tips

Online documentation for GDAL/OGR Python is sparse. Here I show some recommended ways of learning more about GDAL/OGR in Python.

Using Python interpreter

You can learn about GDAL and OGR from inside the Python interpreter.

Start python interpreter:

$ python

Import the modules:

from osgeo import gdal,ogr,osr

Learn about the modules using ‘help’ and ‘dir’ in Python. These built-in functions work for any type of object (module, class, functions etc):

help(ogr) # display help for the ogr module
dir(ogr) # what's contained in ogr module?
help(ogr.Geometry) # display help for ogr.Geometry class
dir(ogr.Geometry) # show contents of an object, like functions on a class

Using gis.stackexchange.com

gis.stackexchange.com is a Q&A site about GIS. Many people here know about GDAL and ORG, also about the Python bindings.

Some good questions I’ve found:

Transformation using OGR in Python
http://gis.stackexchange.com/questions/19401/projecting-shapefile-with-transformation-using-ogr-in-python

Will add more as I find them…

Leave a Reply