Georeference arbitrarily orientated matrix with corresponding lat/lon data

1 view (last 30 days)
I have a 12 x 12 matrix of data ('data'). I also have a 12 x 12 matrix of the corresponding latitudes ('lat')of each cell and another for the longitudes ('lon') of each cell. I need to save the data as a geotiff and cannot find a way to do so. The difficulty comes from the fact lat/lon do not run along parallels/meridians so my efforts with 'georasterref' where you supply the min/max lat/lon of the matrix have failed.
For example, a portion of the lat matrix:
80.3483276367188 80.3870162963867 80.4255905151367
80.3793334960938 80.4181365966797 80.4568405151367
80.4101943969727 80.4491195678711 80.4879379272461
And the lon matrix:
-60.8070793151856 -60.9964065551758 -61.1872444152832
-60.5792732238770 -60.7683334350586 -60.9589118957520
-60.3500404357910 -60.5388183593750 -60.7291259765625
These data were extracted from a netcdf file

Accepted Answer

KSSV
KSSV on 7 Nov 2017
How about doing interpolation and convert it to regular grid and then write to geotiff?
lat = [80.3483276367188 80.3870162963867 80.4255905151367
80.3793334960938 80.4181365966797 80.4568405151367
80.4101943969727 80.4491195678711 80.4879379272461];
lon = [-60.8070793151856 -60.9964065551758 -61.1872444152832
-60.5792732238770 -60.7683334350586 -60.9589118957520
-60.3500404357910 -60.5388183593750 -60.7291259765625];
data = rand(size(lon)) ; % some random data
%%Make regular grid
x0 = min(lon(:)) ; x1 = max(lon(:)) ;
y0 = min(lat(:)) ; y1 = max(lat(:)) ;
x = linspace(x0,x1,3) ; y = linspace(y0,y1,3) ;
[X,Y] = meshgrid(x,y) ;
Z = griddata(lon,lat,data,X,Y) ;

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!