[Gdal-dev] RE: ogr2ogr to PostGIS gives wrong SRID?
Frank Warmerdam
warmerdam at pobox.com
Sat Dec 29 14:54:02 EST 2007
Maciej Sieczka wrote:
> Frank suggests the reason of Randy's problem was that OGR
> could not find a match for his EPSG:4326 translated into
> WKT. Is it my case too? I can see that "SELECT srtext FROM
> spatial_ref_sys WHERE srid=2180" and "SELECT srtext FROM
> spatial_ref_sys WHERE srid=32767" yield exactly the same
> result, only the order of few tags is different.
Maciej,
It is an exact string comparison, so minor formatting,
precision and ordering changes will result in a failure to
match.
> If the comparison of OGR's EPSG->WKT with PostGIS's "srtext"
> is error-prone, could OGR instead just look-up the
> spatial_ref_sys table for "auth_srid" equal to the EPSG code
> specified, check if "auth_name" is "EPSG" and use the
> "auth_srid" value then? That would guarantee that a correct
> EPSG code is used; see:
>
> SELECT srid,auth_name,auth_srid FROM spatial_ref_sys WHERE
> auth_srid=2180;
>
> srid | auth_name | auth_srid
> ------+-----------+-----------
> 2180 | EPSG | 2180
For OGR spatial references with an authority code set, this
would be a valuable pre-search, but it is at most a special
case (though a reasonable common one).
> Hmm, actualy, all "auth_name" fields in my spatial_ref_sys
> are "EPSG", and all "srid" and "auth_srid" are the same; but
> that's maybe just me:
This is common but by no means guaranteed. It would be
wrong to depend on it.
I'd suggest you search for existing open tickets against the postgis
driver on this issue, and append some of the above notes. In particular
the suggestion to first search based on the authority id if it is available.
Hopefully Mateusz can work on some improvements in this area in the coming
months.
I don't have any particular suggested work around at this time.
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 gdal-dev
mailing list