<span class="Apple-style-span" style="border-collapse: collapse; ">Hi Hermann,<div class="im" style="color: rgb(80, 0, 80); "><div><br><div class="gmail_quote">On Wed, Mar 25, 2009 at 9:06 PM, Hermann Peifer <span dir="ltr"><peifer@gmx.eu></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<br>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.<br><br></blockquote></div><br>
</div></div><div>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.</div>
<div><br></div><div>HTH,</div><div><br></div><div>Rob :)</div><div><br></div><div><br></div><div>#!/usr/bin/env python<br></div><div><div><br></div><div>import osr</div><div>import sys</div><div><br></div><div>def main(prj_file):</div>
<div> prj_text = open(prj_file, 'r').read()</div><div> srs = osr.SpatialReference()</div><div> if srs.ImportFromWkt(prj_text):</div><div> raise ValueError("Error importing PRJ information from: %s" % prj_file)</div>
<div> print srs.ExportToProj4()</div><div><br></div><div>if __name__=="__main__":</div><div> main(*sys.argv[1])</div><div><br></div></div></span>