Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '12 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 :) – Francisco Puga May 16 '12 at 23:05

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 opperations) among others (for a comprehensive GIS list, see here: What are the Python tools/modules/add-ins crucial in GIS?). In addition it can interact with PostGIS because PostGIS is based on PostgreSQL.

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 ( ) and you know what you're doing.

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

share|improve this answer

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:

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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