refmatToMapRasterReference

Referencing matrix to map raster reference object

Syntax

R = refmatToMapRasterReference(refmat,rasterSize)
R = refmatToMapRasterReference(___,rasterInterpretation)
R = refmatToMapRasterReference(___,func_name, var_name, arg_pos)
R = refmatToMapRasterReference(Rin,rasterSize, ___)

Description

R = refmatToMapRasterReference(refmat,rasterSize) constructs a map raster reference object, R, from a referencing matrix, refmat, and a size vector, rasterSize.

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

R = refmatToMapRasterReference(___,func_name, var_name, arg_pos) 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 refmatToMapRasterReference for both validating and converting a referencing matrix. The optional inputs work just like their counterparts in the MATLAB® function validateattributes.

R = refmatToMapRasterReference(Rin,rasterSize, ___) verifies that Rin.RasterSize is consistent with rasterSize, then copies Rin to R.

Input Arguments

refmat

Referencing matrix

rasterSize

Size vector [M N ...] specifying the number of rows (M) and columns (N) in the raster or image to be associated with the MapRasterReference 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 = refmatToMapRasterReference(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 specifies basic geometric nature of the raster, either 'cells' or 'postings'.

func_name

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

var_name

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

arg_pos

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

Rin

Map raster reference object.

Output Arguments

R

Map raster reference object.

Examples

Convert a referencing matrix manually versus using the maprasterref function.

% Import a referencing matrix from a world file for a 
% 2000-by-2000 orthoimage referenced to the Massachusetts 
% State Plane Mainland coordinate system.
refmat = worldfileread('concord_ortho_e.tfw')

% Import the corresponding TIFF image and use its size to 
% help convert the referencing matrix to a referencing object.
[X, cmap] = imread('concord_ortho_e.tif');
R = refmatToMapRasterReference(refmat, size(X))

% Use the mapbbox function to obtain the map limits independently 
% of the referencing object.
bbox = mapbbox(refmat, size(X))
xLimWorld = bbox(:,1)';  % Transpose the first column
yLimWorld = bbox(:,2)';  % Transpose the second column

% Construct a referencing object directly, for comparison.
maprasterref('RasterSize', size(X), 'ColumnsStartFrom', 'north', ...
  'XLimWorld', xLimWorld, 'YLimWorld', yLimWorld)
Was this topic helpful?