如何从 shapely Multipoint 数据类型中提取单个点?

问题描述 投票:0回答:1

我用的是shapely2.0;不知何故,我无法在此版本中遍历 MULTIPOINT 数据类型中的各个点。

我想从 MULTIPOINT 中提取和绘制单个点。 MULTIPOINT 是从

line.intersection(circle_boundary)
获得的,我试图在其中获取线和圆几何之间的交点。

有什么方法可以访问 MULTIPOINT 中的各个点或将相交点作为单独的形状点而不是 MULTIPOINT?

python gis geopandas shapely
1个回答
0
投票

多点几何对象可以

exploded
成为基本点对象。

import os
os.environ['USE_PYGEOS'] = '0'
import geopandas as gpd
from shapely.geometry import MultiPoint

s = gpd.GeoSeries(
    [MultiPoint([(0, 0), (1, 1)]), 
     MultiPoint([(2, 2), (3, 3), (4, 4)])]
)

# Create a new geodataframe of individual points
exploded_s = s.explode(index_parts=True)
exploded_s
0 0 点 (0.00000 0.00000)
   1 分 (1.00000 1.00000)
1 0 分 (2.00000 2.00000)
   1 点 (3.00000 3.00000)
   2 点 (4.00000 4.00000)
dtype:几何
© www.soinside.com 2019 - 2024. All rights reserved.