Main Content

Fit Gridded Data to the Graticule

The toolbox projects surface objects in a manner similar to the traditional methods of map making. A cartographer first lays out a grid of meridians and parallels called the graticule. Each graticule cell is a geographic quadrangle. The cartographer calculates or interpolates the appropriate x-y locations for every vertex in the graticule grid and draws the projected graticule by connecting the dots. Finally, the cartographer draws the map data freehand, attempting to account for the shape of the graticule cells, which usually change shape across the map. Similarly, the toolbox calculates the x-y locations of the four vertices of each graticule cell and warps or samples the matrix data to fit the resulting quadrilateral.

In mapping data grids using the toolbox, as in traditional cartography, the finer the mesh (analogous to using a graticule with more meridians and parallels), the greater precision the projected map display will have, at the cost of greater effort and time. The graticule in a printed map is analogous to the spacing of grid elements in a regular data grid, the Mapping Toolbox™ representation of which is two-element vectors of the form [number-of-parallels, number-of-meridians]. The graticule for geolocated data grids is similar; it is the size of the latitude and longitude coordinate matrices: number-of-parallels = mrows-1 and number-of-meridians = ncols-1. However, because geolocated data grids have arbitrary cell corner locations, spacing can vary and thus their graticule is not a regular mesh.

Fit Gridded Data to Fine and Coarse Graticules

This example shows how to fit gridded data to fine and coarse graticules. The choice of graticule is a balance of speed over precision in terms of positioning the grid on the map. Typically, there is no point to specifying a mesh finer than the data resolution (in this example, 180-by-360 grid cells). In practice, it makes sense to use coarse graticules for development tasks and fine graticules for final graphics production.

Note that, regardless of the graticule resolution, the grid data is unchanged. In this case, the data grid is a 180-by-360 matrix, and regardless of where it is positioned, the data values are unchanged.

Load elevation raster data and a geographic cells reference object.

load topo60c

Set up a Robinson projection, specify a coarse (10-by-20) cell graticule, and display the data mapped to the graticule using a colormap appropriate for elevation data. Notice that for this coarse graticule, the edges of the map do not appear as smooth curves.

axesm robinson
spacing = [10 20];
m = meshm(topo60c,topo60cR,spacing);

Now reset the graticule, using the setm function, to make it less coarse, [50 100]. Notice that the jagged edges effect is now negligible.

setm(m,'MeshGrat',[50 100])

Reset the graticule again, this time to a very fine grid using the setm function. Notice that the result does not appear to be any better than the original display with the default [50 100] graticule, but it took much longer to produce. Making the mesh more precise is a trade-off of resolution versus time and memory usage.

setm(m,'MeshGrat',[200 400])