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")

生成了这种类型的 POINT 和 LInesTRING:

         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)。因此我不能使用线串分割方法。此外,该方法的结果是我必须以开头的形式的线串。

所以,我的问题是:

  1. Linestring([(0,10)]) LInesTRING((0 0),(10 10)) 有什么区别?
  2. 我可以将一个转换成另一个吗?
  3. 也许是一个相关的问题:假设我的 geopandas 数据框 df 具有 LInesTRING((0 0),(10 10)) 形式的几何类型列不允许方法 df.exterior.coords。为什么?

感谢您的洞察力!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)