Issue
I'm trying to display points over line strings to debug whether there are multiple points on the same line:
def to_shapely(points: list[point]):
return shapely.ops.unary_union([
shapely.geometry.LineString(points),
shapely.geometry.MultiPoint(points)
])
to_shapely([(0,0), (2,2), (1,0.5)])
This only displays the linestrings however. Is there a way to overlay the points on the linestrings?
Solution
IIUC, you want a GeometryCollection
and not a unary_union
(that returns a single geometry) :
import shapely
def to_shapely(points):
return shapely.geometry.GeometryCollection([
shapely.geometry.LineString(points),
shapely.geometry.MultiPoint(points)
])
to_shapely([(0,0), (2,2), (1,0.5)])
Answered By - Timeless
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.