Looking at the .prj file and searching http://spatialreference.org might also be productive.

Another option is to upload it to spatialreference.org, and you can then get it in a number of formats. This approach isn't recommended for a lot of SRS's, but for a quick one-off sort of thing, it's pretty handy.

Howard

On Mar 25, 2009, at 5:49 AM, Robert Coup wrote:

Hi Hermann,

On Wed, Mar 25, 2009 at 9:06 PM, Hermann Peifer <[email protected]> wrote:

I am looking for a convenient way to convert the SRS parameters from a random shapefile.prj into proj.4 format. A command line interface would be most helpful for a non-programmer, like me.


If you have python on your system (likely), then you can create a python script (eg. prj2proj.py) with the following code in it, then run "python prj2proj.py my.prj" and it'll print the proj4 equivalent of the my.prj file.

HTH,

Rob :)


#!/usr/bin/env python

import osr
import sys

def main(prj_file):
    prj_text = open(prj_file, 'r').read()
    srs = osr.SpatialReference()
    if srs.ImportFromWkt(prj_text):
raise ValueError("Error importing PRJ information from: %s" % prj_file)
    print srs.ExportToProj4()

if __name__=="__main__":
    main(*sys.argv[1])

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to