I'm going to start to create programs to handle geographical data from a PostGIS server, and going to use GDAL.

According to your experience, with the best language to program with it? I can program in Perl and Python, but would like to know the language with more pieces of code to reuse, examples, libraries, etc.

  • 6
    I don't have any proof of it, but my feeling is that Python has many many more libraries and users than Perl. So that's my vote!
    – blah238
    May 16, 2012 at 21:13
  • I think that there are already lots of apps to work with postgis. If you ask another question saying what are your needs, probably you can afford work :) May 16, 2012 at 23:05

4 Answers 4


Personally, I really enjoy coding with GDAL in Python. Once you've got it installed and got your head round how it works it is pretty easy going. Also with python you can make use of some really useful 'batteries included' builtin modules (os, math, string, sys, random etc), as well as third party modules such as NumPy (useful for raster operations) among others.

For a comprehensive list of GIS Python libraries, see here: What are the Python tools/modules/add-ins crucial in GIS?).

A really great introduction to the Python GDAL bindings can be found here:


You can get going in minimal time with a bit of know how and reading, for example you can grab hold of a shapefile in 2 lines:

driver = ogr.GetDriverByName('ESRI Shapefile')
datasource = driver.Open('shapefile.shp')

It's very easy to do whatever you want to the file once you've read through the documentation ( http://www.gdal.org/annotated.html ) and you know what you're doing.

See here for some examples of what is possible in simple and minimal code:



It seems to me this is a pretty subjective question. From the perspective of GDAL/OGR I will say that essentially the same capabilities of the library are exposed in Python and Perl. So a lot may depend on your language preference and what other components you might want.

I am a python guy myself, but I want to speak up a bit on behalf of perl and note that the GeoInformatica environment maintained by Ari Jolma includes GDAL/OGR and a bunch of other useful stuff for perl scripters. I encourage you to check it out:



Without questioning the best language is Python. Because it opens a lot of other possibilities beyond the use of GDAL:

1)With python you can connect to your postgis server with an ORM like SQLAlchemy which will provide many high level functions to handle your data and prepare it for gdal.

2)You can use other python libraries to work with geodata, like Shapely or High Performance Geostatistics Library.

3)You have very good bindings for map output in python, like Mapnik.

4)You have some frameworks and high level APIs which will spare you a lot of work like Geodjango (you can use it locally) or Qgis API.


Third vote for Python. For me, in addition to the excellent answers above, it is because I got fed up with having to know half a dozen scripting languages for different jobs awhile back, so as soon as ESRI supported Python, I dropped them all (nearly - Javascript is still useful) in favour of Python. The great thing is that other non-GIS packages I use also support Python, so I can call GDAL/OGR from the APIs of all sorts of software. Python is also a very high level language so I write about a tenth of the code that even a managed language like C# needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.