Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
5  
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
add comment

4 Answers

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:

http://www.gis.usu.edu/~chrisg/python/2009/

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:

http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/

share|improve this answer
add comment

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:

http://geoinformatics.tkk.fi/

share|improve this answer
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.