I'm trying to cut a line at the intersection, if a line crosses another line within a single multilinestring then and the end of the line is below a maximum distance threshold then it swaps the end of the line co ordinates to the intersection. As shown in this image.
The code I have so far is:
def trim_lines_to_intersection(lines, MAX_DIST): '''If a road intersects with another road, end the road at the intersection if the distance between the endpoint of the line and the intersection is less than MAX_DIST''' # initialize trimmed lines with list of original lines #trimmed_lines = [line for line in lines] trimmed_lines = [LineString(array) for array in lines] #trimming_points = vertices_from_lines(trimmed_lines) for i, line in enumerate(trimmed_lines): for q in [-1]: endpoint = Point(line.coords[q]) for road1, road2 in itertools.combinations(trimmed_lines, 2): x = road1.intersection(road2) if x.distance(endpoint) < MAX_DIST: Point(endpoint.coords[q]) = x return trimmed_lines
coords_SE = [((5, 5), (20, 5)), ((10, 10), (10, 0)), ((15,0), (15,10))]
lines_SE = MultiLineString(coords_SE)
test = trim_lines_to_intersection(lines_SE, 6)
The error I am receiving is: SyntaxError: can't assign to function call.