Matplotlib 如何将cartopy贴图的投影与shapefile的投影匹配?

Matplotlib 如何将cartopy贴图的投影与shapefile的投影匹配?,matplotlib,projection,cartopy,Matplotlib,Projection,Cartopy,我正在尝试将海岸线()地图的投影与shapefile的投影合成,shapefile的.prj文件显示: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984", SPHEROID["WGS_1984",6378137.0,298.257223563]], PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] 我的尝试是: import matplotlib.pyplot as plt import car

我正在尝试将海岸线()地图的投影与shapefile的投影合成,shapefile的.prj文件显示:

GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
我的尝试是:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io import shapereader

# set up a map with coastlines around Auckland:
plt.figure(figsize=(10, 10))
platecarree = ccrs.PlateCarree(globe=ccrs.Globe(datum='WGS84'))

ax = plt.axes(projection=platecarree)
extent = [174.25, 175.25, -37.5, -36.5]
ax.set_extent(extent)
ax.coastlines('10m',color='red')

# read in shapefile and plot the polygons:
shp2 = shapereader.Reader('auckland_geology_wgs84gcs.shp')
formations = shp2.records()

for formation in formations:
     # plot water blue, and all other rocks yellow
     if formation.attributes['MAIN_ROCK'] == b'                                ':
         ax.add_geometries(formation.geometry, ccrs.PlateCarree(),facecolor='blue',alpha=.1)
     else:
         ax.add_geometries(formation.geometry, ccrs.PlateCarree(), facecolor='yellow',alpha=.1)
plt.show()
我试着在platecarree定义中给globe参数指定prj文件中的半径和反向展平,但是如果我设置或更改这些数字,我没有看到输出有任何变化

此外,使用定义的“platecarree”投影(使用WGS84调用globe)作为add_Geometrics调用中的crs,我的输出为空


在我看来,结果就像是我试图用QGIS和从天然地球(10米海岸线)和GADM(新西兰adm0级)下载的数据重现你的问题。看来是NE10m海岸线造成的!GADM与地质层完美对齐,而NE10m已关闭(并变形)