Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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

some shapefiles have a .prj file associated with it. and the .prj file contains the projection info of the shapefile in the format of WKT. Sometimes I need to convert WKT to proj4 string, and sometimes I need to convert it back.

Is there any ready-made library to do this?

Thanks in advance.

share|improve this question

The OGR Spatial Reference part of GDAL should do the trick. capooti provided an excellent answer to another question which demonstrates how to peform the translation from a shapefile to WKT. You may also want to check out the class reference. The reverse is simply:

from osgeo import osr

srs = osr.SpatialReference()
wkt_text = 'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",' \
# Imports WKT to Spatial Reference Object
srs.MorphToESRI() # converts the WKT to an ESRI-compatible format
print "ESRI compatible WKT for use as .prj:" % srs.ExportToWkt()
share|improve this answer
Anyone have a solution that doesn't require osgeo, which doesn't seem to work for Python 3? – Dan Nguyen Feb 22 at 2:51

I don't know any library, but you can use this site to get the translations:

EDIT: I found a python script that works with ogr python bindings to do that. Here it is.

share|improve this answer
thanks, but i need to do that programmatically. – CuiPengFei Apr 14 '11 at 16:11
After some googling: is powered by GDAL as well & uses the same code path (more or less), it seems. – Dan S. Apr 14 '11 at 17:11
That's interesting – Pablo Apr 14 '11 at 18:33

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.