NetCDF and Python: Finding the closest lon/lat index given actual lon/lat values
问题 I'd like to be able to find the lon/lat coordinate indices of the closest location to a lon/lat tuple. This is already available in the Java API as GridCoordSystem.findXYindexFromLatLon(), but I haven't found anything comparable in the Python API. What I'm hoping to find in the API, or write myself and contribute to the API (if useful), is something like this: def get_indices(netcdf_dataset, lon_value, lat_value): ''' :param netcdf_dataset an open NetCDF data set object :param lon_value a