matlab: splitting small arrays by latitude/longitude into individual grid cells of one large array

后端 未结 1 1882
谎友^
谎友^ 2020-12-20 07:11

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

相关标签:
1条回答
  • 2020-12-20 07:42

    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.

    0 讨论(0)
提交回复
热议问题