[postgis-users] spatial_ref_sys entry from .prj file?

Frank Warmerdam warmerdam at pobox.com
Wed Jun 20 13:18:57 PDT 2007


Erich Schroeder wrote:
> Is there a script available to take a shapefile .prj file and create the 
> correct insert statement to make a full new entry to spatial_ref_sys? In 
> my case the contents is:
> 
> PROJCS["Clarke_1866_Lambert_Conformal_Conic",GEOGCS["GCS_Clarke_1866",DATUM["D_Clarke_1866",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",2999994.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-89.5],PARAMETER["Standard_Parallel_1",33.0],PARAMETER["Standard_Parallel_2",45.0],PARAMETER["Latitude_Of_Origin",33.0],UNIT["Foot_US",0.3048006096012192]] 
> 
> 
> Which is I guess the SRTEXT item, but I was hoping for something that 
> would pull out the correct proj4 text from that.

Erich,

Such a script can be constructed using the facilities of the
OGRSpatialReference class (part of the GDAL/OGR library).

Particular care must be taken due to the incompatability of OGC WKT
coordinate system descriptions the the ESRI projection engine strings.
They are similar, but not completely compatible.  For this reason the
OGRSpatialReference class includes a morphFromESRI() method to convert
ESRI WKT to OGC (OGR) WKT.  After that is done you can use the
exportToProj() method to get a corresponding PROJ.4 string.

The ogr2ogr utility will already attempt to do all this if you use
it to load a shapefile into postgis.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the postgis-users mailing list