[gdal-dev] PostGIS SRID conundrum

Martin Chapman chapmanm at pixia.com
Sat Feb 11 00:48:55 EST 2012


Brent,



Thank you very much for the advice.  What I resorted to (at least for the 
present) is:



1.        I try to get the geogcs or projcs (if projected) authority code 
from OGR.  If successful, I try to find a match in the spatial_ref_sys 
table.  If I find a match then I compare the wkt, if it’s exactly the same I 
use it.  If not I go to number 2.

2.       I export the proj4 text from OGR and do a select on the 
spatial_ref_sys table for an exact match.  If found I use that srid.  If not 
I go to number 3.

3.       I export the wkt text from OGR and do a select on the 
spatial_ref_sys table for an exact match.  If found I use that srid.  If not 
I go to number 4.

4.       I select the max(srid) where srid > 10000000.  If zero is returned 
then I  use that base number (10000000) and add a new entry to the 
spatial_ref_sys table using the proj4 text and wkt so all fields have a 
value…and my app name as the authority (makes me feel important J).  If a 
max above 10000000 is found then I take the max and add one and then add the 
new entry.



If you or anyone else can see any flaws in that logic I would appreciate 
some criticism.



Thanks again for your feedback!



Best regards,

Martin



From: pcreso at pcreso.com [mailto:pcreso at pcreso.com]
Sent: Friday, February 10, 2012 10:33 PM
To: Martin Chapman
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] PostGIS SRID conundrum




ESRI does not use a SRID, it uses a text string that needs complex parsing 
to work. If ESRI supported EPSG codes it would be easier...

The spatial_ref_sys table contains entries for all EPSG recognised 
projections. If you have a reasonable case to have a projection inluded by 
EPSG, submit a request to EPSG & it will finish up in the Postgis 
spatial_reference table.

In the short term, add a proj4txt record for your projection with an 
arbitrary new srid in the spatial_ref_sys table & it will work fine in 
Postgis. If you want it to work with GDAL/OGR then you;ll need to add it to 
the proj4 list of projection parameters. Where this is depends on your OS & 
implementation.

See this spec:

http://remotesensing.org/geotiff/proj_list/orthographic.html

The proj4 parameter list for your case may need to specify WGS84 as your 
ellipsoid & datum.

HTH,

  Brent Wood

--- On Sat, 2/11/12, Martin Chapman <chapmanm at pixia.com> wrote:


From: Martin Chapman <chapmanm at pixia.com>
Subject: [gdal-dev] PostGIS SRID conundrum
To: gdal-dev at lists.osgeo.org
Date: Saturday, February 11, 2012, 12:25 PM

I know this question isn’t exactly related to GDAL but I thought someone on 
the list might be able to answer this question.



So, I have a shape file that has the following spatial reference:



PROJCS["Orthographic",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Orthographic"],PARAMETER["Latitude_Of_Center",40],PARAMETER["Longitude_Of_Center",-75],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["User 
Defined",1]]



It was generated using OGR.  I want to insert it into postgres / postgis but 
there is no direct match for the wkt or proj4 definition in the 
spatial_ref_sys table.  So, I go to insert it into the table but the 
question arises, what SRID do I use?  Do I just fudge a random one with a 
high enough value that I hope it won’t conflict with some other SRID in the 
future, or do I create a table based off of the heterogeneous list of SRIDs 
at spatialreference.org and insert from that?  I would like to do the later 
but that will be a pain unless someone has a put together a batch insert sql 
file for all the projections on spatialreference.org.  Still, there is 
always the possibility that I may run into one that isn’t defined and I will 
have to fudge my own number anyway.



Question:  What is the best way to handle this?  I wish the spatial_ref_sys 
table came with all the ESRI and other SRID definitions.



Suggestions are much appreciated!



Best regards,

Martin






-----Inline Attachment Follows-----

_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120211/e2e040f6/attachment-0001.html


More information about the gdal-dev mailing list