I am currently using Geopandas, and I need to search for the k-nearest neigbour efficiently in a data frame. According to the documentation, the implementation of sindex depends on wether or not pygeos is available. Unfortunatly, this change the api for nearest method, which only supports k-nearest when using rtree implementation instead of pygeos.
Is there a way to force geopandas to bypass pygeos and use rtree instead?
Yes. From docs:
You can still toggle the use of PyGEOS when it is available, by:
USE_PYGEOS=0/1
). Note this variable is only checked at first import of GeoPandas.geopandas.options.use_pygeos = True/False
. Note, although this variable can be set during an interactive session, it will only work if the GeoDataFrames you use are created (e.g. reading a file with read_file
) after changing this value.