本文介绍了从Shapely中的多边形中提取点/坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取/提取定义shapely
多边形的点?谢谢!
How do you get/extract the points that define a shapely
polygon?Thanks!
形状多边形的示例
from shapely.geometry import Polygon
# Create polygon from lists of points
x = [list of x vals]
y = [list of y vals]
polygon = Polygon(x,y)
推荐答案
因此,我发现诀窍是结合使用Polygon
类方法来实现.
So, I discovered the trick is to use a combination of the Polygon
class methods to achieve this.
如果需要测地坐标,则需要将其转换回WGS84(通过pyproj
,matplotlib
的basemap
等).
If you want geodesic coordinates, you then need to transform these back to WGS84 (via pyproj
, matplotlib
's basemap
, or something).
from shapely.geometry import Polygon
#Create polygon from lists of points
x = [list of x vals]
y = [list of y vals]
some_poly = Polygon(x,y)
# Extract the point values that define the perimeter of the polygon
x, y = some_poly.exterior.coords.xy
这篇关于从Shapely中的多边形中提取点/坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!