【Python】cnmaps包实现裁剪地图边界和添加九段线

一、效果展示

在这里插入图片描述

二、绘图前准备

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值