如何绘制形状点列表

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

我根据点数据集创建了Shapely Point对象的列表。如何在下面绘制此点列表?

points = [Point(-4.85624511894443, 37.1837967179202), 
          Point(-4.855703975302475, 37.18401757756585),
          Point(-4.85516283166052, 37.1842384372115),
          Point(-4.85343407576431, 37.182006629169),
          Point(-4.85347524651836, 37.1804461589773),
          Point(-4.855792124429867, 37.18108913443582),
          Point(-4.85624511894443, 37.1837967179202)]
plot geometry point shapely
1个回答
0
投票

您可以通过访问xyx属性来获得yPoint坐标的两个列表,然后使用Matplotlib的Pointplt.scatter函数,如下所示:

plt.scatter

plt.plot


[如果使用Jupyter Notebook或Jupyter Lab,则可以将点列表包装在plt.plot对象中以获得SVG图像。当您想快速绘制某些内容而不导入Matpotlib时,这对于调试目的很有用。

import matplotlib.pyplot as plt
from shapely.geometry import Point

points = [Point(-4.85624511894443, 37.1837967179202), 
          Point(-4.855703975302475, 37.18401757756585),
          Point(-4.85516283166052, 37.1842384372115),
          Point(-4.85343407576431, 37.182006629169),
          Point(-4.85347524651836, 37.1804461589773),
          Point(-4.855792124429867, 37.18108913443582),
          Point(-4.85624511894443, 37.1837967179202)]
xs = [point.x for point in points]
ys = [point.y for point in points]
plt.scatter(xs, ys)
# or plt.plot(xs, ys) if you want to connect points by lines

给出:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.