## Georeferenced Raster Data

Raster geodata consists of georeferenced data grids and images that are stored as
matrices or objects in the MATLAB^{®} workspace. While raster geodata looks like any other matrix of real
numbers, what sets it apart is that it is georeferenced, either to the globe or to a
specified map projection, so that each pixel of data occupies a known patch of territory
on the planet.

All regular data grids require a reference object, matrix, or vector, that specify the placement and resolution of the data set. Geolocated data grids do not require a separate reference object, as they explicitly identify the geographic coordinates of all rows and columns. For details on geolocated grids, see Geolocated Data Grids.

### Reference Objects

A spatial reference object encapsulates the relationship between a geographic or
planar coordinate system and a system of intrinsic coordinates anchored to the
columns and rows of a 2-D spatially referenced raster grid or image. A reference
object for raster data that is referenced to a geographic latitude-longitude system
can be a `GeographicCellsReference`

or `GeographicPostingsReference`

object. A referencing object for raster
data referenced to a planar (projected) map coordinate system can be a `MapCellsReference`

or `MapPostingsReference`

object. Unlike the older referencing matrix and
vector representations (described below), a reference object is self-documenting,
providing a rich set of properties to describe both the intrinsic and extrinsic
geometry. The use of reference objects is preferred, but some referencing matrix and
vector functionality continues to be supported for the purpose of
compatibility.

### Referencing Matrices

A referencing matrix is a 3-by-2 matrix of doubles that describes the scaling,
orientation, and placement of the data grid on the globe. For a given referencing
matrix, `R`

, one of the following relations holds between rows and
columns and coordinates (depending on whether the grid is based on map coordinates
or geographic coordinates, respectively):

[x y] = [row col 1] * R, or [long lat] = [row col 1] * R

Convert a referencing matrix to a raster reference object using the `refmatToGeoRasterReference`

or `refmatToMapRasterReference`

functions.

### Referencing Vectors

In many instances (when the data grid or image is based on latitude and longitude
and is aligned with the geographic graticule), a referencing matrix has more degrees
of freedom than the data requires. In such cases, you may encounter a more compact
representation, a three-element *referencing vector*. A
referencing vector defines the pixel size and northwest origin for a regular,
rectangular data grid:

refvec = [cells-per-degree north-lat west-lon]

This variable is often called `refvec`

(or
`maplegend`

). The first element, cells-per-degree, describes
the angular extent of each grid cell (e.g., if each cell covers five degrees of
latitude and longitude, cells-per-degree would be specified as
`0.2`

). Note that if the latitude extent of cells differs from
their longitude extent you cannot use a referencing vector, and instead must specify
a referencing object or matrix. The second element, north-lat, specifies the
northern limit of the data grid (as a latitude), and the third element, west-lon,
specifies the western extent of the data grid (as a longitude). In other words,
north-lat, west-lon is the northwest corner of the data grid. Note, however, that
cell (1,1) is always in the southwest corner of the grid. This need not be the case
for grids or images described by referencing objects or matrices.

Convert a referencing vector to a geographic raster reference object using the
`refvecToGeoRasterReference`

function.