The Python Oracle

geopandas known intersection returns False

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Luau

--

Chapters
00:00 Question
01:50 Accepted answer (Score 3)
02:24 Thank you

--

Full question
https://stackoverflow.com/questions/6838...

Question links:
[image]: https://i.stack.imgur.com/8h6HN.png

Accepted answer links:
[shown in the documentation]: https://geopandas.readthedocs.io/en/late...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #intersection #geopandas

#avk47



ACCEPTED ANSWER

Score 3


You do not select one polygon but one row of the GeoDataFrame. Therefore you are using an intersects on a Series, not a Polygon. As shown in the documentation, geopandas aligns those series and do row-wise 1:1 operation. You need to pass a shapely.geometry if you want to check all rows against a single geometry.

# this is shapely.geometry.Polygon
geom = Dataset1.loc[Dataset1['ID'] == 15000, 'geometry'].iloc[0]

Dataset2.intersects(geom)