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

RuntimeError: b"no options found in 'init' file #101

Closed
mohmad-null opened this issue Dec 15, 2016 · 5 comments
Closed

RuntimeError: b"no options found in 'init' file #101

mohmad-null opened this issue Dec 15, 2016 · 5 comments

Comments

@mohmad-null
Copy link

pyproj-1.9.5.1

If I try and convert from EPSG:404000 to epsg:4326, I get:

post_process_xml - ERROR - Coordinate changing raised an exception
Traceback (most recent call last):
  File "E:/X_Dev/ogc__xml_to_es/src\post_process_xml.py", line 219, in change_coords
    start = pyproj.Proj(init=start_proj)
  File "C:\Python35\lib\site-packages\pyproj\__init__.py", line 358, in __new__
    return _proj.Proj.__new__(self, projstring)
  File "_proj.pyx", line 122, in _proj.Proj.__cinit__ (_proj.c:1578)
RuntimeError: b"no options found in 'init' file"

I'm reasonably confident that this is because the given EPSG (404000) isn't in the proj file (that's what pywps suggests anyway - http://wiki.rsg.pml.ac.uk/pywps/Mapserver ).

However, I'd like to suggest that if that's the case, the exception raised should make this clear, ideally with a unique exception so it can be handled separately from exceptions where the install is bad or bad data is sent to it which also seem to raise a RuntimeError.

@micahcochran
Copy link
Collaborator

I'm reasonably confident that this is because the given EPSG (404000) isn't in the proj file

It is the epsg file, and you are correct that EPSG:404000 (or <404000> in this case) isn't in there.

However, I'd like to suggest that if that's the case, the exception raised should make this clear, ideally with a unique exception so it can be handled separately from exceptions where the install is bad or bad data is sent to it which also seem to raise a RuntimeError.

My initial thought is to like the idea of distinguishing between a bad proj string, and an improper installation. My quick look at PROJ.4 suggests that this might be hard to change in pyproj.

If you try to do what you described from PROJ.4's cs2cs command, you'd have a command line like this which gives an errors like this:

C:\Users\mcochran\Desktop>cs2cs +init=epsg:4326 +to +init=epsg:404000
Using to definition: init=epsg:404000
Rel. 4.9.3, 15 August 2016
<cs2cs>:
projection initialization failure
cause: Unknown error
program abnormally terminated

Thus where the "init" part of the error comes from. There are also esri numeric codes, which are in the esri file. "+init=esri:26916"

That error "no options found in 'init' file" code come from PROJ.4.

I'm not sure that PROJ.4 knows if epsg and related files are installed. If that is true, it would be very cumbersome to make pyproj know if PROJ.4 has access to those file.

@mayanksuman
Copy link

mayanksuman commented Jan 9, 2019

In my case, the conversion to or from EPSG:54032 leads to this runtime error on pyproj: 1.9.6 by using following code.

import pyproj
in_out_crs = ['epsg:4326', 'epsg:54032']
for src, des in in_out_crs: 
    proj_in = pyproj.Proj('+init='+src, preserve_units=True) 
    proj_out = pyproj.Proj('+init='+des, preserve_units=True) 
    pyproj.transform(proj_in, proj_out, lon, lat) 

However my system PROJ.4 (5.2.0) can use this crs. For instance

echo 55.2 12.2 | proj +proj=aeqd +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs

produces 6039191.49 1581288.50. The proj string is obtained from gdalsrsinfo epsg:54032.

I am not sure but it looks like this error in pyproj do not come from system PROJ.4 but from included older version PROJ.4 source file (specifically this line).

Why do pyproj ship its own version of PROJ.4? System PROJ.4 is usually more updated with crs code and other enhancements.

Glad to hear that removing PROJ.4 is being considered.

@micahcochran
Copy link
Collaborator

@mayanksuman Your example of using the longer verson of the proj string with proj isn't a good example.

EPSG:54032 is not in the data/epsg file for pyproj, so therefore it doesn't recognize the projections sting. (Nor is it in the Proj 5.2.0 data/epsg file.)

When I use Proj 5.2.0 with the equivalent command line argument. It gives an error.

C:\Users\mcochran\Desktop>echo 55.2 12.2 | proj +init=epsg:54032
Rel. 5.2.0, September 15th, 2018
<proj>:
projection initialization failure
cause: invalid projection system error (-9999)
program abnormally terminated

Still, you can use Proj("+proj=aeqd +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs")

Glad to hear that removing PROJ.4 is being considered.

I'm glad, too. The datum grid files should also be a github link to the newish repository for those, too.

@snowman2
Copy link
Member

Current version (pyproj==2.1.0) error message seems to be a little more clear:

>>> p1 = pyproj.Proj("EPSG:404000")
proj_create: crs not found
Traceback (most recent call last):
...
pyproj.exceptions.CRSError: Invalid projection: epsg:404000

@snowman2
Copy link
Member

Closing as the error messages are more clear now. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants