2016-06-30 40 views
1

我想合成一个海岸线的预测()地图与shape文件,其.prj文件中说:如何将我的cartopy映射与shapefile的投影相匹配?

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定义中的参数是prj文件的半径和逆平坦度,但是如果我设置或甚至改变这些数字,我没有看到输出的任何更改。

此外,在add_geometries调用中,使用定义的“platecarree”投影(以WGS84调用全球)作为crs,我的输出为空白。

原样,结果在我看来就像a projection mismatch

回答

1

我试图重现使用QGIS和数据从自然地球(10米海岸线)下载,并从GADM(NZ ADM0级)你的问题。看起来NE10m海岸线是罪魁祸首! GADM与您的地质层完美对齐,而NE10m关闭(和变形)。 screenshot of QGIS with Geological map & coastlines