spatialdata
spatialdata copied to clipboard
Bug with pygeos makes sjoin fail
If incompatible versions of pygeos
, geopandas
and shapely
are installed one may encounter bugs with geopandas
or reduced performance. In an extreme case I just saw sjoin
fail with the following error:
...
File "/Users/macbook/miniconda3/envs/ome/lib/python3.11/site-packages/pygeos/decorators.py", line 80, in wrapped
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/macbook/miniconda3/envs/ome/lib/python3.11/site-packages/pygeos/predicates.py", line 159, in is_empty
return lib.is_empty(geometry, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: One of the arguments is of incorrect type. Please provide only Geometry objects.
We should investigate better which versions of shapely
, geopandas
and pygeos
are compatible and we recommend and report the incompatible versions to the developers of the respective libraries.
A workaround in case this happens is to add this in the code before import geopandas
, shapely
or pygeos
# isort: off
import os
# os.environ["USE_PYGEOS"] = "0"
# isort:on
or to set the following in bash before running the code
export USE_PYGEOS=0
Thank you for this issue, had the same problem and not using pygeos solved the problem, amazing.
Fixed with https://github.com/scverse/spatialdata/pull/545