Split a linestring at each point it crosses a polygon in shapely
问题 I have a linestring which spans various polygons, stored as GeoJsons. I want to split the line into individual parts within each polygon area. I have not been able to achieve this yet, however. This is a reproducible example for what I have so far: from shapely.geometry import Point, LineString, Polygon from shapely.ops import split from matplotlib import pyplot as plt poly = { 'type': "Feature", 'geometry': { "type": "Polygon", "coordinates": ([(2,2),(2,4),(4,4),(4,2)]), }, 'properties': {