karimbahgat / PyCRS

Projection creation, and conversion to misc formats
MIT License
98 stars 20 forks source link

Exception: The specified projection name 'Meter' could not be found #35

Closed forkozi closed 5 years ago

forkozi commented 5 years ago

Hi. I'm excited to use PyCRS, but I've run into a glitch. When I use from_ogc_wkt() on the following wkt...

'PROJCS["NAD83 / UTM zone 17N",GEOGCS["NAD83 / UTM zone 17N",DATUM["NAD83",SPHEROID["GRS80",6378137.000,298.257222100,AUTHORITY["EPSG","0"]],AUTHORITY["EPSG","0"]],PRIMEM["Greenwich",0.0000000000000000,AUTHORITY["EPSG","8901"]],UNIT["Degree",0.01745329251994329547,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","26917"]],UNIT["Meter",1.00000000000000000000,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0.0000000000000000],PARAMETER["central_meridian",-81.0000000000000000],PARAMETER["scale_factor",0.9996000000000000],PARAMETER["false_easting",500000.000],PARAMETER["false_northing",0.000],AXIS["Easting",EAST],AXIS["Northing",NORTH],AXIS["Height",UP],AUTHORITY["EPSG","26917"]]

...I get the following.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Nick.Forfinski-Sarko\AppData\Local\Continuum\anaconda3\envs\qaqc_checker\lib\site-packages\pycrs\parse.py", line 92, in from_ogc_wkt
    return _from_wkt(string, "ogc", strict)
  File "C:\Users\Nick.Forfinski-Sarko\AppData\Local\Continuum\anaconda3\envs\qaqc_checker\lib\site-packages\pycrs\parse.py", line 406, in _from_wkt
    crs = _parse_top(header, content)
  File "C:\Users\Nick.Forfinski-Sarko\AppData\Local\Continuum\anaconda3\envs\qaqc_checker\lib\site-packages\pycrs\parse.py", line 294, in _parse_top
    raise Exception("The specified projection name %r could not be found" % projname)
Exception: The specified projection name 'Meter' could not be found

I 'thought' this was an OCG string, but maybe not?

Thanks for sharing your module.

Nick

karimbahgat commented 5 years ago

This was caused by a parsing error, where the code expected the projection element to be in the second position, which is not always the case. Fixed to make it more flexible, and tested that your string now works.

forkozi commented 5 years ago

Awesome. Thanks for the quick fix! Will the updated module become available on pip?

karimbahgat commented 5 years ago

Now on PyPI as version 1.0.1.