sjoin one-to-one option if intersection overlaps several polygon
See original GitHub issueI have a grid poly (qk
) which I want to join attributes from admin boundaries (ph
). For each poly in qk I want to take attributes of the first located feature in ph I (one-to-one).
I can’t find an ption in sjoin to do this, instead it always (one-to-many).
See example code here and viz in QGIS below:
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Spatially joining only features by largest overlap with sjoin in ...
Therefore I want to ask how to filter out and restrict to a single area, like selecting only output file entries with the...
Read more >Spatial Join (Analysis)—ArcGIS Pro | Documentation
Join one to one—If multiple join features are found that have the same spatial ... For this option, the target features can only...
Read more >Spatial Join's hidden trick or how to transfer attribute values in ...
Run the tool. The resulting dataset should display zones that each of the property boundary polygons intersect, stored as text values separated ...
Read more >How Spatial Join Works in GIS - GISGeography
The spatial join tool inserts the columns from one feature table to another based on location or proximity. It can affix one or...
Read more >Spatial Join gives <Null> to joined features - Esri Community
Join one to one. Intersect / within etc. all give same result. Join_count gives me 0. Also, when I use the polygon data...
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 FreeTop 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
Top GitHub Comments
@cyrchi you can first do
sjoin_nearest
then apply additional predicates to the pairs of geometries from your source and target data frames to further filter the results to remove those that only intersect at the boundary, or use a centroid (or some other representative geometry) of your source and target geometries and take the one with the least distance per source (left) geometry.We’d have to develop additional functionality at a lower level (i.e., shapely) to get at the concept of joining to nearest but not overlapping geometries, if that is a common activity to be doing with
sjoin_nearest
.@martinfleis Looking at your implementation I’m sure it is faster. Was not aware of query_bulk.
notice you don’t do any CRS transformation within the method but guess that’s actually the right call since if you are not using projected CRS then geopandas will raise anyway.
Tobler looks like a useful lib - wasn’t aware of it before - thanks