Documentation

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.

geoloc2grid

Convert geolocated data array to regular data grid

Syntax

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

Description

[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.

Examples

% 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);
set(f,'Colormap',cmap,'Color','w')
 
% Define map limits
latlim = [-35 70];
lonlim = [0 100];
 
% Display 'map1' as a geolocated data array in subplot 1
subplot(1,2,1)
ax = axesm('mercator','MapLatLimit',latlim,...
   'MapLonLimit',lonlim,'Grid','on',...
   'MeridianLabel','on','ParallelLabel','on');
set(ax,'Visible','off')
geoshow(lt1, lg1, map1, 'DisplayType', 'texturemap');
 
% Display 'Z' as a regular data grid in subplot 2
subplot(1,2,2)
ax = axesm('mercator','MapLatLimit',latlim,...
   'MapLonLimit',lonlim,'Grid','on',...
   'MeridianLabel','on','ParallelLabel','on');
set(ax,'Visible','off')
geoshow(Z, refvec, 'DisplayType', 'texturemap');

More About

collapse all

Tips

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?