Drape Geolocated Grid on Regular Data Grid via Texture Mapping

This example shows how to create a new regular data grid that covers the region of the geolocated data grid, then embed the color data values into the new matrix. The new matrix might need to have somewhat lower resolution than the original, to ensure that every cell in the new map receives a value. The example combines dissimilar data grids by creating a new regular data grid that covers the region of the geolocated data grid's z-data. This approach has the advantage that more computational functions are available for regular data grids than for geolocated ones. Color and elevation grids do not have to be the same size. If the resolutions of the two data grids are different, you can create the surface as a three-dimensional elevation map and later apply the colors as a texture map. You do this by setting the surface CData property to contain the color matrix, and setting the surface face color to 'texturemap'.

Load elevation raster data and a geographic cells reference object from topo60c.mat. Get individual variables containing terrain data from mapmtx.mat.

load topo60c
load mapmtx lt1 lg1 map1

Identify the geographic limits of the geolocated grid that was loaded from mapmtx.

latlim(1) = 2*floor(min(lt1(:))/2);
lonlim(1) = 2*floor(min(lg1(:))/2);
latlim(2) = 2*ceil(max(lt1(:))/2);
lonlim(2) = 2*ceil(max(lg1(:))/2);

Crop the global elevation data to the rectangular region enclosing the smaller grid.

[topo1,topo1R] = geocrop(topo60c,topo60cR,latlim,lonlim);

Allocate a regular grid filled uniformly with -Inf, to receive texture data.

L1R = georefcells(latlim,lonlim,2,2);
L1 = zeros(L1R.RasterSize);
L1 = L1 - Inf;

Overwrite L1 using imbedm, converting it from a geolocated grid to a regular grid, in which the values come from the discrete Laplacian of the elevation grid map1.

L1 = imbedm(lt1,lg1,del2(map1),L1,L1R);

Set up a map axes with the Miller projection and use meshm to display the cropped data. Render the figure as a 3-D view from a 20 degree azimuth and 30 degree altitude, and exaggerate the vertical dimension by a factor of 200. Both the surface relief and coloring represent topographic elevation.

figure 
axesm miller
h = meshm(topo1,topo1R,size(topo1),topo1);
view(20,30)
daspectm('m',200)

Apply the L1 matrix as a texture map directly to the surface using the set function. The area not covered by the [lt1,lg1,map1] geolocated data grid appears dark blue because the corresponding elements of L1 were set to -Inf.

h.CData = L1;
h.FaceColor = 'texturemap';
material shiny 
camlight
lighting gouraud
axis tight