关于降水落区插值色斑图的地图和maskout的疑惑

请问一下第一行的,裁截地图中的'haerbin/hrb.shp','hrb'这个应该怎么用,第八行中的 if shape_rec.record[2] == region:的[2]特征值应该怎么看呢?谢谢

clip = maskout.shp2clip(cf,ax,'haerbin/hrb.shp','hrb') #haerbin/shijie.shp shp/黑龙江省/市界.shp
import shapefile
from matplotlib.path import Path
from matplotlib.patches import PathPatch
def shp2clip(originfig,ax,shpfile,region):

sf = shapefile.Reader(shpfile,encoding='utf-8')
for shape_rec in sf.shapeRecords():
    if shape_rec.record[2] == region:  ####这里需要找到和region匹配的唯一标识符,record[]中必有一项是对应的。
        vertices = []
        codes = []
        pts = shape_rec.shape.points
        prt = list(shape_rec.shape.parts) + [len(pts)]
        for i in range(len(prt) - 1):
            for j in range(prt[i], prt[i+1]):
                vertices.append((pts[j][0], pts[j][1]))
            codes += [Path.MOVETO]
            codes += [Path.LINETO] * (prt[i+1] - prt[i] -2)
            codes += [Path.CLOSEPOLY]
            clip = Path(vertices, codes)
            clip = PathPatch(clip, transform=ax.transData)
for contour in originfig.collections:
    contour.set_clip_path(clip)
return clip
        

maskout模块或shp2clip函数是用于在绘图时用于屏蔽外部图形,匹配出需要绘图的区域。其中'hrb'是作为要显示区域的参数传递。shape_rec.record[2]其中的[2]是指shape_rec.record列表中索引第二个元素,这是shp数据文件记录中的一个字段,在if语句的前面加上print(shape_rec.record)就可以查看到。如果匹配,则构建一个matplotlib绘图实例对象。具体实现的例子及shp文件内容查看方式见这个链接文章及讨论内容。
python 绘制降水量色斑图_小杨丿的博客-CSDN博客 # 引用部分import numpy as npimport pandas as pdfrom scipy.interpolate import Rbf # 径向基函数 : 将站点信息插到格点上 用于绘制等值线import matplotlib.pyplot as pltimport matplotlib.colors as colorsimport matplotlib as m... https://blog.csdn.net/qq_39425958/article/details/104790575