This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Convert geolocated data array to regular data grid


[Z, refvec] = geoloc2grid(lat, lon, A, cellsize)


[Z, refvec] = geoloc2grid(lat, lon, A, cellsize) converts the geolocated data array A, given geolocation points in lat and lon, to produce a regular data grid, Z, and the corresponding three-element referencing vector refvec. cellsize is a scalar that specifies the width and height of data cells in the regular data grid, using the same angular units as lat and lon. Data cells in Z falling outside the area covered by A are set to NaN.


% Load the geolocated data array 'map1' 
% and grid it to 1/2-degree cells.
load mapmtx
cellsize = 0.5;
[Z, refvec] = geoloc2grid(lt1, lg1, map1, cellsize);
% Create a figure
f = figure;
[cmap,clim] = demcmap(map1);
% Define map limits
latlim = [-35 70];
lonlim = [0 100];
% Display 'map1' as a geolocated data array in subplot 1
ax = axesm('mercator','MapLatLimit',latlim,...
geoshow(lt1, lg1, map1, 'DisplayType', 'texturemap');
% Display 'Z' as a regular data grid in subplot 2
ax = axesm('mercator','MapLatLimit',latlim,...
geoshow(Z, refvec, 'DisplayType', 'texturemap');

More About

collapse all


geoloc2grid provides an easy-to-use alternative to gridding geolocated data arrays with imbedm. There is no need to preallocate the output map; there are no data gaps in the output (even if cellsize is chosen to be very small), and the output map is smoother.

Introduced before R2006a

Was this topic helpful?