[gdal-dev] OGRSpatialReference::MorphFromESRI handling WKT with single quotes returned by ArcGIS geoprocessor API

Jason Roberts jason.roberts at duke.edu
Wed Sep 9 17:29:06 EDT 2009


I am trying to understand how to use OGR to process spatial reference WKT
obtained from ArcGIS. I have noticed that ArcGIS WKT strings returned by
ESRI's geoprocessing API includes single quotes around names of things:

 

>>> import arcgisscripting

>>> gp = arcgisscripting.create()

>>> d = gp.Describe(r'C:\Eddies\DT_MSLA\Rasters\ssh2008002')

>>> esriWKT = gp.CreateSpatialReference(d.SpatialReference).split(';')[0]

>>> esriWKT

"PROJCS['User_Defined_Mercator',GEOGCS['GCS_User_Defined',DATUM['D_User_Defi
ned',SPHEROID['User_Defined_Spheroid',6371000.0,0.0]],PRIMEM['Greenwich',0.0
],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator'],PARAMETER['False
_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',
0.0],PARAMETER['Standard_Parallel_1',0.0],UNIT['Meter',1.0]]"

 

As I understand it, WKT is formally specified by OGC in the document
"OpenGIS Implementation Specification for Geographic information - Simple
feature access - Part 1: Common architecture". The latest version, 1.2.0, is
available at http://www.opengeospatial.org/standards/sfa. On pages 75-76,
the various names are declared to be <quoted name>, which pages 53-55 say
are <name>s enclosed in double quotes. This means that ESRI's API is not
returning compliant WKT.

 

The OGRSpatialReference class includes a MorphFromESRI method. I hoped it
might handle the single quotes, but it does not:

 

>>> o = osr.SpatialReference(esriWKT)

>>> o.MorphFromESRI()

0

>>> print(o.ExportToPrettyWkt())

PROJCS["'User_Defined_Mercator'",

    GEOGCS["'GCS_User_Defined'",

        DATUM["'D_User_Defined'",

            SPHEROID["'User_Defined_Spheroid'",6371000.0,0.0]],

        PRIMEM["'Greenwich'",0.0],

        UNIT["'Degree'",0.0174532925199433]],

    PROJECTION["'Mercator'"],

    PARAMETER["'False_Easting'",0.0],

    PARAMETER["'False_Northing'",0.0],

    PARAMETER["'Central_Meridian'",0.0],

    PARAMETER["'Standard_Parallel_1'",0.0],

    UNIT["'Meter'",1.0]]

>>> o.GetLinearUnitsName()

"'Meter'"

 

It is simple enough for my application to convert the single quotes to
double quotes before calling OGR. But would it be appropriate for a future
release of the MorphFromESRI method to handle this automatically? This would
improve compatibility between OGR and data produced by ArcGIS.

 

Thanks,

Jason

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090909/61a5ee37/attachment.html


More information about the gdal-dev mailing list