文章目录
一、效果展示
二、绘图前准备
1.用于绘图的网格数据集
2.地图shapefile文件
3.九段线shapefile文件
4.安装并导入cnmaps包
conda环境安装教程:无需手动安装
conda activate myenvs(自定义环境)
conda install cnmaps
三、python代码
1.导入cnmaps包
from cnmaps import clip_contours_by_map
2.完整绘图代码
import numpy as np
import netCDF4 as nc
import matplotlib as mlp
import matplotlib.pyplot as plt
from matplotlib import colors
from matplotlib import ticker
from matplotlib.path import Path
from matplotlib.patches import PathPatch
import scipy
import os
import xarray as xr
import pandas as pd
import geopandas as gpd
import shapefile as shp
import cmaps
from cartopy.io.shapereader import Reader
from cartopy.util import add_cyclic_point
import cartopy.crs as ccrs
import cartopy.mpl.ticker as cticker
import cartopy.feature as cfeature
from typing import List
from cnmaps import clip_contours_by_map
#读取地图和九段线shapefile文件
China = gpd.read_file('/map/china-shapefiles/china_country.shp')
nine_dotted_line = gpd.read_fil