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 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

Basic geometric nature of the raster, specified as either 'cells' or 'postings'.

funcName

Name used in the formatted error message to identify the function checking the input, specified as a character vector.

varName

Name used in the formatted error message to identify the referencing matrix, specified as a character vector.

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:

% Specify the size of a sample raster and referencing matrix.
rasterSize = [180 360];
refmat = [0 1; 1 0; -0.5 -90.5];
 
% Convert the referencing matrix to a
% geographic raster reference object.
R = refmatToGeoRasterReference(refmat,rasterSize);
 
% For comparison, construct a referencing object directly.
R2 = georasterref( ...
   'RasterSize',rasterSize,'Latlim',[-90 90],'Lonlim',[0 360]);
Introduced in R2011a