Combine Vector and Raster Geodata on the Same Map

Vector map variables and data grid variables are often used or displayed together. For example, continental coastlines in vector form might be displayed with a grid of temperature data to make the latter more useful. When several map variables are used together, regardless of type, they can be referred to as a single map. To do this, of course, the different data sets must use the same coordinate system (i.e., geographic coordinates on the same ellipsoid or an identical map projection).

Combining Raster Data and Vector Data on the Same Map

This example shows how to combine raster data and vector data on the same map.

Load the coastline vector data.

load coastlines

Load the topo raster data set.

load topo

Create a raster referencing object associated with the topo data set.

topoR = georefcells(topolatlim,topolonlim,size(topo))
topoR = 
  GeographicCellsReference with properties:

             LatitudeLimits: [-90 90]
            LongitudeLimits: [0 360]
                 RasterSize: [180 360]
       RasterInterpretation: 'cells'
           ColumnsStartFrom: 'south'
              RowsStartFrom: 'west'
       CellExtentInLatitude: 1
      CellExtentInLongitude: 1
     RasterExtentInLatitude: 180
    RasterExtentInLongitude: 360
           XIntrinsicLimits: [0.5 360.5]
           YIntrinsicLimits: [0.5 180.5]
       CoordinateSystemType: 'geographic'
                  AngleUnit: 'degree'

Create a map axes, using axesm, specifying the Robinson projection. Then plot the raster data on the axes with an appropriate color map.

axesm robinson;

Plot the coastline data in red on top of the terrain map. You can use geoshow to display both raster and vector data.