Metpy 给定点的插值

Metpy Interpolate values for the given point

我用的是这个Metpy的插值方法https://unidata.github.io/MetPy/latest/examples/gridding/Point_Interpolation.html#sphx-glr-examples-gridding-point-interpolation-py。我的问题是如何获取给定点的内插温度值,在本例中是从纽约的图像中获取的?所以,我得到了纬度和经度,我得到了那一点的温度值。 enter image description here

在示例代码中,数据被投影到使用以下方法创建的阿尔伯斯等面积投影上的网格:

 import cartopy.crs as ccrs
 to_proj = ccrs.AlbersEqualArea(central_longitude=-97.0000, central_latitude=38.0000)

您可以使用 to_proj 将您的 lat/lon 转换为投影坐标:

 pt_x, pt_y = to_proj.transform_point(lon, lat, ccrs.Geodetic())

然后您可以使用 pt_xpt_ygxgy 数组(在原始示例代码中创建)中找到最接近的索引来拉取img 数组中的数据值。

如果您真的只关心特定位置的值,您可能需要查看 MetPy 的 interpolate_to_points 函数。

好的,我使用这个命令解决了问题:

proj = ccrs.PlateCarree()
to_proj = ccrs.Mercator()

back_to_lon = precx.ravel()
back_to_lat = precy.ravel()
back_to_prec = prec_p.ravel()

pt_x = proj.transform_points(to_proj,back_to_lon,back_to_lat,back_to_prec)

enter image description here