import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import my_class
filename = r"D:\lunwen\lunwenshuju\DEM\cldasgrid_dem.nc"
f = xr.open_dataset(filename)
dem = f["elevation"]
lon = f["LON"]
lat = f["LAT"]
# 筛选区域
dim1 = (lon>=75)&(lon <= 96)
dim2 = (lat>=35)&(lat<=51)
dem = dem[dim2, dim1]
min_dem = np.min(dem)
max_dem = np.max(dem)
var = (max_dem-min_dem)/10
lon = lon[dim1]
lat = lat[dim2]
lon, lat = np.meshgrid(lon, lat)
plt.rcParams.update({'font.size': 13})
# 解决中文乱码问题
plt.rcParams['font.sans-serif'] = ['KaiTi']
# 解决负号乱码问题
plt.rcParams['axes.unicode_minus'] = False
fig = plt.figure(figsize=[15, 7])
ax1 = fig.add_subplot(111, projection=ccrs.PlateCarree())
ax1.set_xticks(np.arange(75, 95 +2.5, 2.5), crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(35, 55 + 2.5, 2.5), crs=ccrs.PlateCarree())
xtick_str = ['75', ' ', '80', ' ', '85', ' ', '90', ' ',
Python画地形图(以新疆地区为例)
于 2022-07-25 00:18:23 首次发布