The Python Oracle

geopandas known intersection returns False

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

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

--

Chapters
00:00 Geopandas Known Intersection Returns False
01:06 Accepted Answer Score 3
01:32 Thank you

--

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

--

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)