MATLAB: How to plot a cell referenced map

cellsgeoshowMATLABreference

I am trying to create a "cell referenced" map with data from an M by N matrix "topo". Can this be done using the "geoshow" function?

Best Answer

You can create a "cell referenced" plot by first creating a "GeographicCellsReference" object using the function "georefcells". The code below illustrates this workflow using a built-in MATLAB example:
>>load topo
>>R = georefcells(topolatlim, topolonlim, size(topo));
>>worldmap world
>>setm(gca,'mapprojection','pcarree');
>>S = geoshow(topo, R, 'DisplayType','texturemap');
Note that here, "topolatlim" and "topolonlim" specify the limits of the latitude and the longitude in increasing order (i.e. from South to North and West to East, respectively).
For releases R2015a and earlier, the function "georefcells" is not available. In earlier releases, replace the line of code that calls "georefcells" with
>>R = georasterref('LatLim',topolatlim,'LonLim',topolonlim,'RasterSize',size(topo));
Also note that the built-in example is slightly different in earlier releases, so it is necessary to construct "topolatlim" and "topolonlim" from the data in the MAT file.