Looking for a fast way to find the polygon a point belongs to using Shapely

Use Rtree (examples) as R-tree index to: (1) index the bounds of the 36k polygons (do this just after reading jsonfile), then (2) very quickly find the intersecting bounding boxes of each polygon to your point of interest. Then, (3) for the intersecting bounding boxes from Rtree, use shapely to use, e.g. point.within(p) to do … Read more

Coordinates of the closest points of two geometries in Shapely

The GIS term you are describing is linear referencing, and Shapely has these methods. # Length along line that is closest to the point print(line.project(p)) # Now combine with interpolated point on line p2 = line.interpolate(line.project(p)) print(p2) # POINT (5 7) An alternative method is to use nearest_points: from shapely.ops import nearest_points p2 = nearest_points(line, … Read more