geopandas相关操作

geopandas–提取gdf中的geometry中的x,y

if gdf['geometry'].geom_type[0] == 'Point':
    gdf['x'] = gdf['geometry'].apply(lambda geom: geom.x)
    gdf['y'] = gdf['geometry'].apply(lambda geom: geom.y)

gdf.gemetry合并(unary_union)

gdf.plot()

geopandas相关操作_第1张图片

gdf.geometry
0    LINESTRING (114.18080 30.50960, 114.18454 30.5...
1    LINESTRING (114.18454 30.50746, 114.18823 30.5...
2    LINESTRING (114.18224 30.51141, 114.18940 30.5...
Name: geometry, dtype: geometry
gdf.geometry.unary_union

geopandas相关操作_第2张图片

type(gdf.geometry.unary_union)
shapely.geometry.multilinestring.MultiLineString

你可能感兴趣的:(geopandas,python,数学建模)