tomalrussell / snkit

spatial networks toolkit (python)
MIT License
31 stars 10 forks source link

Compatibility with geopandas pygeos STRTree #37

Closed tomalrussell closed 2 years ago

tomalrussell commented 3 years ago

Recent geopandas (since at lease 0.9) uses pygeos.STRTree as the spatial index if pygeos is installed, or else continues to use rtree.index.Index.

snkit currently uses the .nearest functionality from the rtree.index.Index.

As a workaround, if a recent geopandas and pygeos are installed, we can force compatibility by doing:

import geopandas as gpd
gpd._compat.USE_PYGEOS = False
import snkit

It looks like future pygeos - https://github.com/pygeos/pygeos/blob/b74773d5a7abbcfdf645ebd52b1ca4836a3fee80/pygeos/strtree.py#L180 - will have some variant of nearest and there's some discussion about the spatial index API compatibility going forward in geopands - https://github.com/geopandas/geopandas/issues/1344

tomalrussell commented 2 years ago

Closed by https://github.com/tomalrussell/snkit/commit/9a1a7dc04f427cbb4e01303c433cb015f5a68964