如何解决POLYGON((x1 x2), (x3 x4), (x5 x6), (x7 x8)) 和 POLYGON([(x1,x2), (x3,x4), (x5,x6), (x7,x8) 的区别)])
我对使用 geopandas
和更一般的 GIS 方法相当陌生,我对如何定义和表示对象有点困惑,主要是因为我找到的一些解决问题的解决方案要求输入数据采用另一种形式,而不是我设法生成的形式。
让我举例说明:
假设我想把一个 Linestring 分成 6 个相等的段,那么这个方法就完美了:
from shapely.geometry import Linestring,MultiPoint
from shapely.ops import split
line = Linestring([(0,0),(10,10)])
splitter = MultiPoint([line.interpolate((i/4),normalized=True) for i in range(1,4)])
split(line,splitter).wkt
返回:
'GEOMETRYCOLLECTION (LInesTRING (0 0,2.5 2.5),LInesTRING (2.5 2.5,5 5),LInesTRING (5 5,7.5 7.5),LInesTRING (7.5 7.5,10 10))'
用我的方法(在我的数据上)
zone_short_edges['line'] = zone_short_edges.apply(lambda row: Linestring([row['fr_point'],row['to_point']]),axis=1) #Create a linestring column
zone_short_edges['midpoint'] = zone_short_edges.apply(lambda row: row['line'].centroid,axis=1) #Find centroid
zone_short_edges = zone_short_edges.set_geometry("line")
zone_short_edges = zone_short_edges.set_geometry("midpoint")
id vertex_id fr_point \
1 Allé 119 2 POINT (119.79008 28.35047)
3 Allé 119 4 POINT (122.85067 44.85106)
to_point seg_length \
1 POINT (122.85067 28.08433) 3.072140
3 POINT (119.92314 44.71798) 2.930553
line \
1 LInesTRING (119.79008 28.35047,122.85067 28.0...
3 LInesTRING (122.85067 44.85106,119.92314 44.7...
midpoint
1 POINT (121.32038 28.21740)
3 POINT (121.38690 44.78452)
即LInesTRING (119.79008 28.35047,122.85067 28.0454,122.3434 23.323)
。因此我不能使用线串分割方法。此外,该方法的结果是我必须以开头的形式的线串。
所以,我的问题是:
-
Linestring([(0,10)])
和LInesTRING((0 0),(10 10))
有什么区别? - 我可以将一个转换成另一个吗?
- 也许是一个相关的问题:假设我的 geopandas 数据框 df 具有
LInesTRING((0 0),(10 10))
形式的几何类型列不允许方法df.exterior.coords
。为什么?
感谢您的洞察力!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。