Rasterio: 1.2b2 from wheel can't locate proj.db

Created on 11 Jan 2021  路  4Comments  路  Source: mapbox/rasterio

The PROJ search path isn't set properly. I had thought that the tests run by the wheel builder would find such bugs, but no.

$ rio info ~/projects/rasterio/tests/data/RGB.byte.tif 
Traceback (most recent call last):
  File "rasterio/_base.pyx", line 1455, in rasterio._base._osr_from_crs
  File "rasterio/_err.pyx", line 192, in rasterio._err.exc_wrap_int
rasterio._err.CPLE_AppDefinedError: PROJ: proj_create_from_database: cannot build projectedCRS 32618: SQLite error on SELECT extent.description, extent.south_lat, extent.north_lat, extent.west_lon, extent.east_lon, scope.scope, (CASE WHEN scope.scope LIKE '%large scale%' THEN 0 ELSE 1 END) AS score FROM usage JOIN extent ON usage.extent_auth_name = extent.auth_name AND usage.extent_code = extent.code JOIN scope ON usage.scope_auth_name = scope.auth_name AND usage.scope_code = scope.code WHERE object_table_name = ? AND object_auth_name = ? AND object_code = ? ORDER BY score, usage.auth_name, usage.code: no such table: usage

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sean/.local/bin/rio", line 8, in <module>
    sys.exit(main_group())
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/rasterio/rio/info.py", line 90, in info
    info['lnglat'] = src.lnglat()
  File "rasterio/_base.pyx", line 986, in rasterio._base.DatasetBase.lnglat
  File "rasterio/_base.pyx", line 1394, in rasterio._base._transform
  File "rasterio/_base.pyx", line 1461, in rasterio._base._osr_from_crs
rasterio.errors.CRSError: PROJ: proj_create_from_database: cannot build projectedCRS 32618: SQLite error on SELECT extent.description, extent.south_lat, extent.north_lat, extent.west_lon, extent.east_lon, scope.scope, (CASE WHEN scope.scope LIKE '%large scale%' THEN 0 ELSE 1 END) AS score FROM usage JOIN extent ON usage.extent_auth_name = extent.auth_name AND usage.extent_code = extent.code JOIN scope ON usage.scope_auth_name = scope.auth_name AND usage.scope_code = scope.code WHERE object_table_name = ? AND object_auth_name = ? AND object_code = ? ORDER BY score, usage.auth_name, usage.code: no such table: usage
bug

All 4 comments

This looks like the culprit: https://github.com/mapbox/rasterio/blob/master/rasterio/_env.pyx#L372. Older, incompatible PROJ data previously installed on my system is being found and the data in the module is ignored.

@sgillies I posted the same in https://rasterio.groups.io/g/main/message/673
@snowman2 replied that it might be linked to https://pyproj4.github.io/pyproj/stable/gotchas.html#internal-proj-error-sqlite-error-on-select but I haven't tried

Here is the search logic used by pyproj in case it is helpful: docs | code

1. The one set by pyproj.datadir.set_data_dir (if exists & valid)
2. The internal proj directory (if exists & valid)
3. The directory in PROJ_LIB (if exists & valid)
4. The directory on sys.prefix (if exists & valid)
5. The directory on the PATH (if exists & valid)

@snowman2 thanks! I think I've got something equivalent in #2080.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

snowman2 picture snowman2  路  4Comments

valpesendorfer picture valpesendorfer  路  3Comments

sgillies picture sgillies  路  5Comments

sgillies picture sgillies  路  4Comments

Giangblackk picture Giangblackk  路  3Comments