Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: The specified projection name 'Mercator_Auxiliary_Sphere' could not be found #34

Open
patdaburu opened this issue Feb 21, 2019 · 7 comments

Comments

@patdaburu
Copy link

Hello. I'm very excited about this project. It's what the World needs now. I'm just getting started but have hit an error pretty early. I'm trying to load this projection: http://spatialreference.org/ref/sr-org/6928/

I've tried a few different ways as prescribed by the documentation, but pretty consistently get this exception:

Traceback (most recent call last): File "/home/pat/.PyCharm2018.3/config/scratches/pycrs_test_1.py", line 58, in <module> """) File "/home/pat/sandbox/pycrs-test/venv/lib/python3.6/site-packages/pycrs/parse.py", line 92, in from_ogc_wkt return _from_wkt(string, "ogc", strict) File "/home/pat/sandbox/pycrs-test/venv/lib/python3.6/site-packages/pycrs/parse.py", line 406, in _from_wkt crs = _parse_top(header, content) File "/home/pat/sandbox/pycrs-test/venv/lib/python3.6/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 'Mercator_Auxiliary_Sphere' could not be found

I've tried loading it from the a shapefile using pycrs.load.from_file and below I've included attempts using the ESRI WKT and OGC WKT directly:

crs = pycrs.parse.from_esri_wkt(""" PROJCS[ "WGS_1984_Web_Mercator_Auxiliary_Sphere", GEOGCS[ "GCS_WGS_1984", DATUM[ "D_WGS_1984", SPHEROID["WGS_1984",6378137.0,298.257223563] ], PRIMEM[ "Greenwich",0.0], UNIT["Degree",0.017453292519943295] ], PROJECTION[ "Mercator_Auxiliary_Sphere" ], PARAMETER["False_Easting",0.0], PARAMETER["False_Northing",0.0], PARAMETER["Central_Meridian",0.0], PARAMETER["Standard_Parallel_1",0.0], PARAMETER["Auxiliary_Sphere_Type",0.0], UNIT["Meter",1.0] ] """)

crs = pycrs.parse.from_ogc_wkt(""" PROJCS[ "WGS_1984_Web_Mercator_Auxiliary_Sphere", GEOGCS[ "GCS_WGS_1984", DATUM[ "D_WGS_1984", SPHEROID["WGS_1984",6378137.0,298.257223563] ], PRIMEM["Greenwich",0.0], UNIT["Degree",0.0174532925199433]], PROJECTION["Mercator_Auxiliary_Sphere"], PARAMETER["False_Easting",0.0], PARAMETER["False_Northing",0.0], PARAMETER["Central_Meridian",0.0], PARAMETER["Standard_Parallel_1",0.0], PARAMETER["Auxiliary_Sphere_Type",0.0], UNIT["Meter",1.0], AUTHORITY["ESRI","102100"] ] """)

It seems to not like GEOCS.PROJECTION ("Mercator_Auxiliary_Sphere"), but I'm not sure how to work around it. Please let me know if I can provide additional information.

Thank you again. This is great!

@karimbahgat
Copy link
Owner

Glad to hear you're finding it useful!

This issue arises because the Mercator_Auxiliary_Sphere projection has not yet been added/supported. Adding it would be as easy as finding the equivalent names for OGC WKT, ESRI WKT, and proj4 and adding a new class to pycrs.elements.projections. The WKT ones are fine, but I cannot seem to find the equivalent proj4 representation. Eg in the link you posted the proj4 link is just empty.

It would be possible adding it withtout the proj4 representation, which simply would mean you would get an error when converting to proj4. However, it seems the use of the projection actually carries with it some implications that change the values of other parameters, plus adding a special "Auxiliar_Sphere_Type" parameter. Here is a relevant link that seems to discuss some of the implications of this projection: https://trac.osgeo.org/gdal/ticket/3962

Because of these additional implications, I don't want to support it until we fully understand the projection and if we need to add code that changes other parameters. I don't have time to explore it right now, but hopefully we'll get this sorted out at some point (help much appreciated).

@markcoletti
Copy link

Just giving this a bump because I ran into this very issue just now:

crs = pycrs.load.from_url('https://spatialreference.org/ref/sr-org/7262/ogcwkt/')
Traceback (most recent call last):
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-51-ecddadeec1de>", line 1, in <module>
    crs = pycrs.load.from_url('https://spatialreference.org/ref/sr-org/7262/ogcwkt/')
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/pycrs/load.py", line 53, in from_url
    crs = func(string)
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/pycrs/parse.py", line 755, in from_unknown_text
    crs = from_unknown_wkt(text, strict)
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/pycrs/parse.py", line 132, in from_unknown_wkt
    return _from_wkt(string, None, strict)
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/pycrs/parse.py", line 415, in _from_wkt
    crs = _parse_top(header, content)
  File "/Users/may/anaconda/envs/eagle-i/lib/python3.6/site-packages/pycrs/parse.py", line 303, in _parse_top
    raise NotImplementedError("Unsupported projection: The specified projection name %r could not be found in the list of supported projections" % projname)
NotImplementedError: Unsupported projection: The specified projection name 'Mercator_Auxiliary_Sphere' could not be found in the list of supported projections

@karimbahgat
Copy link
Owner

I would need some more insight and feedback on the implication in terms of this projection altering the values of other parameters, and whether it has a proj4 equivalent. See my previous post. Hopefully someone knowledgeable on the topic will be able to help.

@dmi3coder
Copy link

dmi3coder commented Jan 21, 2020

Had same issue while working with Mercator_Auxiliary_Sphere. Looks like PyProj can parse it with no issues, so if you need to get projection you can use code similar to

with open(folder_name + '/' + file_name + '.prj', 'r') as file:
    data = file.read().replace('\n', '')
proj = Proj(data, preserve_units=True)

Maybe there's some references that can be taken from PyProj to fix it in this repo

@karimbahgat
Copy link
Owner

If you'd be able to look into the PyProj code for this, a PR would be greatly appreciated :)

@giswqs
Copy link

giswqs commented Dec 29, 2020

I am running into the same NotImplementedError: Unsupported projection: The specified projection name 'Mercator_Auxiliary_Sphere' could not be found in the list of supported projections

@karimbahgat
Copy link
Owner

Since this issue keeps coming up, I would really like to fix this one. I nevertheless still don't know the right answer here, so would need someone that could do a deep dive into this.

Here's another link that may be relevant: https://gis.stackexchange.com/questions/61823/ogr-projection-transformation-error

Based on my rudimentary reading of web mercator, it is essentially just a mercator projection where in addition the ellipsoid is a perfectly round sphere, ie no flattening factor. So if this is correct, we might be able to parse it by simply setting the projection to mercator, while also somehow forcing the WKT spheroid flattening factor to 0 or setting proj4 +a and +b to the same (which seems to be the case for https://spatialreference.org/ref/sr-org/45/).

Based on the gdal issue tracker referenced earlier, this might not be sufficient, as the projection formula itself might need to be told to use a spherical instead of ellipsoidal forumal. It seems that ESRI WKT does this when using 'Mercator_Auxiliary_Sphere', but that OGC WKT lacks this projection, and might need to be set to 'Mercator_1SP' plus maybe some other parameters...

I'm hoping someone can confirm or refute any of this, but unless I hear anything else, I might consider just implementing that along with raising a warning.

@karimbahgat karimbahgat pinned this issue Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants