Я пытался сделать это с помощью растворения, но это не работает
Код: Выделить всё
import geopandas as gpd
import pandas as pd
from shapely.geometry import MultiLineString
data = {
"type": "FeatureCollection",
"name": "lines",
"features": [
{ "type": "Feature", "properties": { "Text": "A" },
"geometry": { "type": "MultiLineString",
"coordinates": [ [ [ 0.0, 0.0, 0.0 ], [ 10.0, 0.0, 0.0 ] ] ] } },
{ "type": "Feature", "properties": { "Text": "B" },
"geometry": { "type": "MultiLineString",
"coordinates": [ [ [ 0.0, 0.0, 0.0 ], [ 16.37797725526616, 0.0, 0.0 ] ] ] } },
{ "type": "Feature", "properties": { "Text": "C" },
"geometry": { "type": "MultiLineString",
"coordinates": [ [ [ 0.0, 0.0, 0.0 ], [ 4.247235166607424, 7.041334981156978, 0.0 ],
[ 16.742636807728559, 8.986970615165774, 0.0 ] ] ] } },
{ "type": "Feature", "properties": { "Text": "D" },
"geometry": { "type": "MultiLineString",
"coordinates": [ [ [ 0.0, 0.0, 0.0 ], [ 4.247235166607424, 7.041334981156978, 0.0 ] ] ] } }
]
}
features = data['features']
geometries = []
properties = []
for feature in features:
coords_3d = feature['geometry']['coordinates']
coords_2d = [[(x, y) for x, y, z in line] for line in coords_3d]
multiline = MultiLineString(coords_2d)
geometries.append(multiline)
properties.append(feature['properties'])
df = pd.DataFrame(properties)
gdf = gpd.GeoDataFrame(df, geometry=geometries)
[img]https:// i.sstatic.net/fE8Smb6t.jpg[/img]
Объединение перекрывающихся элементов
Подробнее здесь: https://stackoverflow.com/questions/790 ... oncatenate