如果一个shp文件的投影方式是这样,那python画图或者用于掩膜都是个问题。因此需要改改投影方式。查了网上用pyproj、geopandas改投影的代码都不太行。因此这里手动改改。请教了师门的伙伴,终于能行了。
第一,
第二:
第三:
这样就好啦!
从这样变成这样
之后保存文件:
如下代码可实现画图:
import pandas as pd
import numpy as np
import statsmodels.api as sm
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter
import numba as nb
from cartopy.io.shapereader import Reader
fig = plt.figure(figsize=[12,18])
ax = fig.add_subplot(111,projection=ccrs.PlateCarree(central_longitude=0))
ax.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=1.5, zorder=10)
ax.add_feature(cfeature.LAKES.with_scale('110m'),color='k', zorder=10)
shp_path = r'D:\Postgraduate\1'
gla_area = cfeature.ShapelyFeature(Reader(shp_path + '\\' + 'Export_Output.shp').geometries(),ccrs.PlateCarree(), edgecolor='blue',facecolor='none')
ax.add_feature(gla_area, linewidth=0.6, zorder=10, color='blue')
结果如下:
下期打算记录下python如何实现掩膜,再见。