question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IndexError when conducting spatial join with empty polygons

See original GitHub issue

Hey, 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:closed
  • Created 5 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisvandenbosschecommented, Sep 26, 2019

so I hope we will be able to merge it before 0.6 release

That sounds good!

0reactions
julietsitroncommented, Sep 26, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found