0

I have coordinate data consisting of two 6-digit numbers (e.g., 300,000 250,000) that I want to convert into long., lat. coordinates. I'm told that the coordinate data (referred to as GLNX, GLNY) come from the Michigan State Plane coordinate system, EPSG number ESRI:102121 However, when I pass that 102121 number to gdal.ImportFromEPSG, it complains that it knows it not. Two questions:

  1. How do I create a SpatialReference for ESRI:102121
  2. Can I pass my 6-digit number pair directly to reProject, or do I need to "adjust" it, e.g., scale by some power of 10, or convert from feet to meters, or what?
Erica
  • 2,399
  • 5
  • 26
  • 34
user3124028
  • 51
  • 1
  • 3
  • GDAL reference for [importFromEPSG](http://www.gdal.org/classOGRSpatialReference.html#a8a5b8c9a205eedc6b88a14aa0c219969) -- "The coordinate system definitions are normally read from the EPSG derived support files ... and falling back to search for a PROJ.4 epsg init file or a definition in epsg.wkt." Check that [the 102121 projection](http://spatialreference.org/ref/esri/102121/html/) is in those support files. – Erica Apr 21 '16 at 14:19

1 Answers1

0

I'm not sure how you are using the GDAL API, but with GDAL 2.0 through Python, this works for me:

from osgeo import osr
osr.UseExceptions()
sr = osr.SpatialReference()
sr.ImportFromEPSG(102121)  # returns 0 for success, which I get

But I suspect this does not work, as described in your question. So you can import from the PROJ.4 code instead, which you can get from http://epsg.io/102121 or add a .proj4 extension to the raw code:

import urllib2
srid = 102121
response = urllib2.urlopen('http://epsg.io/%d.proj4' % (srid,))
sr.ImportFromProj4(response.read())  # returns 0 for success
print(sr.ExportToPrettyWkt())  # shows that it is understood

The PROJ.4 code is ultimately used by libproj to do the actual projection, not the WKT.

Mike T
  • 41,085
  • 18
  • 152
  • 203