我有两个shapefile.一个是点特征shapefile,名为“point.shp”,另一个是名为“polygon.shp”的多边形shapefile.我想用cartopy添加到地图.
我设法添加“polygon.shp”,但失败了“point.shp”.
这是我的代码:
import matplotlib.pyplot as plt
from cartopy import crs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFeature
ax = plt.axes(projection=crs.PlateCarree())
# add the polygon file, worked
ax.add_geometries(Reader("polygon.shp").geometries(), crs.PlateCarree(), facecolor='w')
# or(also worked):
ax.add_feature(ShapelyFeature(Reader("polygon.shp").geometries(), crs.PlateCarree(), facecolor='r'))
# but these two ways both failed with the "point.shp"
ax.add_geometries(Reader("point.shp").geometries(), crs.PlateCarree())
# or, this doesn't work neither:
ax.add_feature(ShapelyFeature(Reader("polygon.shp").geometries(), crs.PlateCarree(), facecolor='r'))
有没有人知道如何做到这一点,或为什么,没有检索所有点’x,y coords然后绘制它们?
使用坐标(x,y值),ax.plot()可以工作,但是ax.scatter()会失败,为什么?
谢谢