
Convert a MULTILINESTRING to a sorted LINESTRING
Source:R/multiline_to_sorted_linestring.R
multiline_to_sorted_linestring.RdConvert a MULTILINESTRING to a sorted LINESTRING
Details
The function takes a MULTILINESTRING object and converts it to a LINESTRING object by sorting the linestrings and combining them in the correct order.
The sorting criteria is based on the geometric distance between the endpoint of the current linestring
and the endpoints of the remaining linestrings. The linestring with the minimum distance
to the endpoint of the current linestring is selected as the next linestring.
The algorithm starts either from the start_point (if provided) or from the first linestring
in the MULTILINESTRING object and continues until all linestrings are sorted.