Given a cube with lat/lon coordinates
surface altitude [m] / (m) (latitude: 21600; longitude: 43200)
Dimension coordinates:
latitude x -
longitude - x
Attributes:
Conventions: CF-1.4
description: GTOPO30 surface elevation dataset
history: Mon Aug 19 14:04:58 2013: ncrename -v surface altitude,surface_altitude...
institution: Institute of Environmental Physics, University of Bremen, Germany.
label: surface altitude [m]
least_significant_digit: 4
source: http://eros.usgs.gov/#/Find_Data/Products_and_Data_Available/gtopo30_i...
title: Global surface elevation from the GTOPO30
and given a list of lat/lon coordinates, how can I interpolate the cube's data to the given points? (For now, nearest-neighbor would be fine, but for coarser cubes, splines would be nice)
PS: For nearest-neighbor, this interpolation should not depend on loading the whole cube into memory.
The nearest neighbour code in Iris, sadly, currently loads the data to identify the indexes needed. I've submitted a trivial pull request (made complex by testing) to fix this (https://github.com/SciTools/iris/pull/707) which you could try using to work with this sized dataset.
I'm going to work with a cube from the sample data:
And I can check whether there is data loaded with the following function:
So:
Basically, the interface (http://scitools.org.uk/iris/docs/latest/iris/iris/analysis/interpolate.html#iris.analysis.interpolate.extract_nearest_neighbour) for nearest neighbour allows you to do a point extraction:
Notice how the extraction has actually picked the nearest latitude value to my requested point. One thing that is really important is to note that this function really doesn't handle wrapping if your longitude coordinate is not circular:
Notice how the longitude range in the original cube (0-360) now means that the nearest value to -180 is actually 0.
There is also a function to do a trajectory extraction (http://scitools.org.uk/iris/docs/latest/iris/iris/analysis/trajectory.html?highlight=trajectory#iris.analysis.trajectory.interpolate):
Finally, notice how the original cube's data has not been loaded throughout (using my branch), and indeed, the data from smaller_cube has also been deferred:
For the trajectory, in general, deferred loading is not possible, but it is worth noting that when using NetCDF the indices are being passed right through to the underlying NetCDF library so that at no point is the entire array in memory.
HTH!
P.S. I'm not aware of any spline interpolation algorithms which work with Iris yet, though there is a similar interface to do linear interpolation, should that be of interest.