Using multiple predicate parameters on sjoin in GeoPandas

601
1
02-15-2022 11:49 AM
BenCutting
New Contributor

Looking for a way to run GeoDataFrame.sjoin() with more than one predicate. For Example, on QGIS' "Join by location" tool, there is a check box of predicates to mark as needed.

When trying to run predicates as a list :

my_sjoin = gdf_1.sjoin(gdf_2, predicate=['within', 'intersects'])

The function wont accept a list:

"TypeError: unhashable type: 'list' "

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

Intersects is a pretty broad predicate, and would include all features returned by within. You shouldn't really need both.

GeoPandas uses Shapely for spatial joins, and you can read more about the binary predicates here: https://shapely.readthedocs.io/en/latest/manual.html#binary-predicates

- Josh Carlson
Kendall County GIS
0 Kudos