I have a geodataframe (download link) that contains the geometry of bus lines. It is a Multilinestring. I need to transform the geometry into a single Linestring.
My first idea was to use .explode (GeoPandas).
sel = gpd.read_file(".../sel_overflow.geojson")
exp_sel = sel
exp_sel.explode()
Result:
As you can see, the .explode() splitted the Multilinestring into two Linestrings.
Furthermore, I used shapely linemerge and I got the same Multilinestring back.
from shapely.ops import linemerge
geometry = sel.loc[0, 'geometry']
shapely_object = geometry
line = linemerge(shapely_object)
gdf = gpd.GeoDataFrame(index=[0], crs='epsg:32718', geometry=[line])