擅长:python、mysql、java
<p>您可以直接从包含一组<code>shapely.MultiLineString</code>s的功能中获取绘制线的坐标。作为概念证明,请查看以下代码:</p>
<pre><code>import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
fig, (ax1,ax2) = plt.subplots(nrows=2, subplot_kw = dict(projection=ccrs.PlateCarree()))
ax1.add_feature(cfeature.COASTLINE)
for geom in cfeature.COASTLINE.geometries():
for g in geom.geoms:
print(list(g.coords))
ax2.plot(*zip(*list(g.coords)))
plt.show()
</code></pre>
<p>这张图片是:</p>
<p><a href="https://i.stack.imgur.com/5y92b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5y92b.png" alt="result of the above code"/></a></p>
<p>换句话说,您可以通过访问该特性的<code>MultiLineString</code>来迭代该特性的<code>geometries()</code>。这些<code>MultiLineString</code>中的每一个都包含一个或多个<code>LineString</code>,它们有一个可以转换成列表的<code>coords</code>属性。希望这有帮助。在</p>