refmatToGeoRasterReference

Referencing matrix to geographic raster reference object

Syntax

R = refmatToGeoRasterReference(refmat,rasterSize)
R = refmatToGeoRasterReference(___,rasterInterpretation)
R = refmatToGeoRasterReference(___,funcName,varName,argIndex)
R = refmatToGeoRasterReference(Rin,rasterSize,___)

Description

R = refmatToGeoRasterReference(refmat,rasterSize) constructs a cell-oriented geographic raster reference object, R, from a referencing matrix, refmat, and a size vector, rasterSize.

R = refmatToGeoRasterReference(___,rasterInterpretation) uses the rasterInterpretation input to determine which type of geographic raster reference object to construct. The rasterInterpretation input indicates basic geometric nature of the raster, and can equal either 'cells' or 'postings'.

R = refmatToGeoRasterReference(___,funcName,varName,argIndex) uses up to three optional arguments to provide additional information. This information is used to construct error messages if either the refmat or rasterSize inputs turn out to be invalid. Thus, you can use refmatToGeoRasterReference for both validating and converting a referencing matrix. The optional inputs work just like their counterparts in the MATLAB® function validateattributes.

R = refmatToGeoRasterReference(Rin,rasterSize,___) verifies that size of the geographic raster reference object, Rin is consistent with the size specified by rasterSize, and then copies Rin to R. refmatToGeoRasterReference gets size information from the Rin.RasterSize property.

Input Arguments

refmat

Any valid referencing matrix. The matrix must lead to valid latitude and longitude limits when combined with rasterSize, and the matrix columns and rows must be aligned with meridians and parallels, respectively.

rasterSize

Size vector [M N ...] specifying the number of rows (M) and columns (N) in the raster or image to be associated with the geographic raster reference object, R. For convenience, rasterSize may be a row vector with more than two elements. This flexibility allows you to specify the size in the following way:

R = refmatToGeoRasterReference(refmat, size(RGB))

where RGB is M-by-N-by-3. However, in such cases, only the first two elements of the size vector are actually used. The higher (non-spatial) dimensions are ignored.

rasterInterpretation

Text string that indicates basic geometric nature of the raster, either 'cells' or 'postings'.

funcName

String that specifies the name used in the formatted error message to identify the function checking the input.

varName

String that specifies the name used in the formatted error message to identify the referencing matrix.

argIndex

Positive integer that indicates the position of the referencing matrix checked in the function argument list. refmatToGeoRasterReference includes this information in the formatted error message.

Rin

Geographic raster reference object.

Output Arguments

R

Geographic raster reference object.

Examples

Convert a referencing matrix to a geographic raster reference object:

% Construct a referencing matrix for a regular grid that covers the 
% entire globe with 1-degree cells.
rasterSize = [180 360];
refmat = makerefmat( ...
   'RasterSize', rasterSize, 'Latlim', [-90 90], ...
   'Lonlim', [0 360])
 
% Convert to a geographic raster reference object.
R = refmatToGeoRasterReference(refmat, rasterSize)
 
% For comparison, construct a referencing object directly.
georasterref( ...
   'RasterSize', rasterSize, 'Latlim', [-90 90], 'Lonlim', [0 360])
Was this topic helpful?