I have multiple satellite orbit paths that cover different latitudes/longitudes, but are all bounded by the same overall lat/lon grid (below). I am trying to split the data
Assuming you want to have averages per grid cell, check out this thread on MathCentral.
The outline is as follows: round the coordinates in your data to some positive integer, e.g. round(x/edgelenth-min(X))+1
. The round
makes sure it's an integer, edgelength
is some variable you can set if you want for instance half a degree cells instead of 1 degree, min(X)
shifts the origin to 0 and the +1
makes it end up at 1, since MATLAB cannot work with zero index. You can use the same for y
, or LAT,LON.
These rounded values you can then group using sparse(lat,lon,z)
, where z
is the data (I'm assuming heights here). Alternatively, if you want to extract more information, use accumarray
, for e.g. standard deviations:
datastd = accumarray([LAT LON],z,[],@std,[],issparse);
I'm using this technique on data sets containing some 800M LAT/LON combinations in approximately 5 minutes on a grid with 0.5m edgelength and 1x1km total size.