【发布时间】:2016-02-20 17:44:01
【问题描述】:
我希望能够找到离 lon/lat 元组最近的位置的 lon/lat 坐标索引。这已经在 Java API 中作为 GridCoordSystem.findXYindexFromLatLon() 提供,但我在 Python API 中没有找到任何可比的东西。我希望在 API 中找到,或者自己编写并为 API 做出贡献(如果有用的话)是这样的:
def get_indices(netcdf_dataset, lon_value, lat_value):
'''
:param netcdf_dataset an open NetCDF data set object
:param lon_value a longitude value, in degrees (-180...180)
:param lat_value a latitude value, in degrees (-90...90)
:return indices into the lon and lat coordinate variables corresponding to the closest point to the lon/lat value arguments
'''
# some (trigonometry?) code here...
return lon_index, lat_index
也许这并不像我想象的那么复杂,我可以只使用最近的邻居吗?
提前感谢任何 cmets 或建议。
【问题讨论】: