Xavier,
You haven't indicated your target language.
On 12-11-17 08:22 AM, xavier lhomme wrote:
Hi
How to get the EPSG Code from a OSR.SpatialReference ?
In C++ you could do something like:
int nPCS = -1;
if( poSRS->GetAuthorityName("PROJCS") != NULL
&& EQUAL(poSRS->GetAuthorityName("PROJCS"),"EPSG") )
{
nPCS = atoi(poSRS->GetAuthorityCode("PROJCS"));
}
This works for projected coordinate systems. For geographic
coordinate systems you could replace PROJCS with GEOGCS.
I would add that for coordinate systems without existing AUTHORITY
entries with the EPSG codes it can be helpful to run the
AutoIdentifyEPSG() method on the OGRSpatialReference. This will make
a somewhat feeble attempt to recognise EPSG coordinate systems and
attach the authority codes.
Is there some explample to create an ESRI ISpatialReference from a
OSR.SpatialReference ?
I am not familiar with ISpatialReference, but with an OGRSpatialReference
you can call morphToESRI() to switch the coordinate system definition
format to match what is expected by the ArcGIS Projection Engine and
then fetch the string out with ExportToWkt(). In Python this might look
something like:
srs = ogr.SpatialReference()
srs.ImportFromEPSG(4202)
srs.MorphToESRI()
pe_wkt = srs.ExportToWkt()
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, [email protected]
light and sound - activate the windows | http://home.gdal.org/warmerda
and watch the world go round - Rush | Geospatial Software Developer
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev