IndexError when conducting spatial join with empty polygons
See original GitHub issueHey, not sure if this addressed elsewhere, but a search of past results suggests it’s not.
import geopandas, numpy, shapely.geometry as geom
center = geom.Point((0,0))
circle = center.buffer(1)
empty = center.buffer(0)
empty_df = geopandas.GeoDataFrame(geometry=[circle, empty])
points = [geom.Point(x) for x in numpy.random.random(size=(10,2))]
points_df = geopandas.GeoDataFrame(geometry=points)
geopandas.sjoin(points_df, empty_df, op='intersects') # raises an IndexError but completes
I get a result from this join, but I also get an IndexError:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
_ctypes/callbacks.c in 'calling callback function'()
~/anaconda3/envs/ana/lib/python3.7/site-packages/rtree/index.py in py_next_item(p_id, p_mins, p_maxs, p_dimension, p_data, p_length)
708 # xmin, xmax, ymin, ymax, zmin, zmax
709 for i in range(dimension):
--> 710 mins[i] = coordinates[i*2]
711 maxs[i] = coordinates[(i*2)+1]
712
IndexError: list index out of range
Not sure how this IndexError relates to the result, but I didn’t see another issue mentioning this, so I thought I’d raise it.
rtree 0.8.3 geopandas 0.4.1 shapely 1.6.4.post1
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Geopandas spatial join giving empty result [closed]
Both are in CRS EPSG:3946. To get the points contained in each polygon, I do gpd.sjoin(df_points, df_poly, op = 'within').
Read more >spatial join returns with empty feature class with error 999999
Spatial Join ??? tool that I would like to join point data which are completely within polygon data. If I don???t change any...
Read more >Changelog — GeoPandas 0.12.2+0.gefcb367.dirty ...
Return empty data frame rather than raising an error when performing a spatial join with non overlapping geodataframes (#335). Bug fixes: Compatibility with ......
Read more >Joining points to polygons in geopandas creating an empty ...
Looking at the geometry of the polygon dataframe, it appears that the CRS is not actually EPSG:4326, whose coordinates should represent ...
Read more >Spatial Join (Analysis)—ArcGIS Pro | Documentation
Contains—The features in the join features will be matched if a target feature contains them. The target features must be polygons or polylines....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That sounds good!
@martinfleis @jorisvandenbossche thank you!