Main Content

refmatToMapRasterReference

Convert referencing matrix to map raster reference object

    Description

    Create Reference Object

    R = refmatToMapRasterReference(refmat,rasterSize) converts the referencing matrix refmat into a reference object for a raster of cells referenced to planar coordinates, using the raster size rasterSize.

    example

    R = refmatToMapRasterReference(refmat,rasterSize,rasterInterpretation) specifies the geometric nature of the raster. When the raster contains posting point samples referenced to planar coordinates, specify rasterInterpretation as "postings". The default for rasterInterpretation is "cells", which specifies a raster of cells.

    Note

    Instead of converting a referencing matrix to a reference object, you can create a reference object directly.

    • Create a reference object for a raster of cells referenced to planar coordinates by using the maprefcells function.

    • Create a reference object for a raster of posting points referenced to planar coordinates by using the maprefpostings function.

    Validate Inputs

    R = refmatToMapRasterReference(___,funcName), when refmat or rasterSize is invalid, includes the specified function name in generated error identifiers. This syntax uses any combination of input arguments from previous syntaxes, and is useful when you want to both validate and convert a referencing matrix. For more information about validating inputs, see the validateattributes function.

    R = refmatToMapRasterReference(___,funcName,varName) includes the specified variable name in generated error messages.

    R = refmatToMapRasterReference(___,funcName,varName,argIndex) includes the position of the referencing matrix in generated error messages.

    R = refmatToMapRasterReference(Rin,rasterSize,___) verifies that the RasterSize property of the map raster reference object Rin matches rasterSize, and then returns Rin in R.

    Examples

    collapse all

    Specify a sample referencing matrix and the size of a sample raster. Then, convert the referencing matrix to a map raster reference object.

    refmat = [0 -1; 1 0; 208999.5 913000.5];
    rasterSize = [2000 2000];
    R = refmatToMapRasterReference(refmat,rasterSize)
    R = 
      MapCellsReference with properties:
    
                XWorldLimits: [209000 211000]
                YWorldLimits: [911000 913000]
                  RasterSize: [2000 2000]
        RasterInterpretation: 'cells'
            ColumnsStartFrom: 'north'
               RowsStartFrom: 'west'
          CellExtentInWorldX: 1
          CellExtentInWorldY: 1
        RasterExtentInWorldX: 2000
        RasterExtentInWorldY: 2000
            XIntrinsicLimits: [0.5 2000.5]
            YIntrinsicLimits: [0.5 2000.5]
          TransformationType: 'rectilinear'
        CoordinateSystemType: 'planar'
                ProjectedCRS: []
    
    
    

    For comparison, create a reference object directly by using the maprefcells function.

    xlimits = [209000 211000];
    ylimits = [911000 913000];
    R2 = maprefcells(xlimits,ylimits,rasterSize,"ColumnsStartFrom","north")
    R2 = 
      MapCellsReference with properties:
    
                XWorldLimits: [209000 211000]
                YWorldLimits: [911000 913000]
                  RasterSize: [2000 2000]
        RasterInterpretation: 'cells'
            ColumnsStartFrom: 'north'
               RowsStartFrom: 'west'
          CellExtentInWorldX: 1
          CellExtentInWorldY: 1
        RasterExtentInWorldX: 2000
        RasterExtentInWorldY: 2000
            XIntrinsicLimits: [0.5 2000.5]
            YIntrinsicLimits: [0.5 2000.5]
          TransformationType: 'rectilinear'
        CoordinateSystemType: 'planar'
                ProjectedCRS: []
    
    
    

    Input Arguments

    collapse all

    Referencing matrix, specified as a 3-by-2 matrix. A referencing matrix defines a transformation that maps intrinsic coordinates to world coordinates.

    Specify refmat so that [xwyw]=[xiyi1]refmat, where (xi, yi) is a location in intrinsic coordinates and (xw, yw) is the same location in world coordinates.

    Data Types: double

    Number of rows and columns of the raster, specified as a two-element vector of the form [m n], where m is the number of rows and n is the number of columns.

    For convenience, you can specify this argument as a vector with more than two elements, such as the size of an RGB image (m-by-n-by-3). The refmatToMapRasterReference function uses only the first two elements of the size vector.

    Geometric nature of the raster, specified as one of these options:

    • "cells" — The raster is a grid of quadrangular cells. The boundary of the raster is made up of the outermost boundaries of the outermost cells.

    • "postings" — The raster is a grid of posting point samples. The boundary of the raster is made up of sampling points along the edge of the raster.

    For more information about cells and posting points, see Spatially Reference Imported Rasters.

    The corresponding RasterInterpretation property of the reference object is read-only after you create the object.

    Data Types: char | string

    Name of the function for validation, specified as a character vector or as a string scalar. If you specify an empty character vector, '', or the <missing> string, then the refmatToMapRasterReference function ignores the funcName input.

    Data Types: char | string

    Name of the input variable, specified as a character vector or a string scalar. If you specify an empty character vector, '', or the <missing> string, then the refmatToMapRasterReference function ignores the varName input.

    Data Types: char | string

    Position of the input argument, specified as a positive integer.

    Data Types: double

    Map raster reference object, specified as a MapCellsReference or MapPostingsReference object.

    If you specify both Rin and rasterInterpretation, the RasterInterpretion property of Rin must match the value of rasterInterpretation.

    Output Arguments

    collapse all

    Map raster reference object, returned as a MapCellsReference or MapPostingsReference object. The value of R depends on the value of the rasterInterpretation argument.

    rasterInterpretationR
    "cells"MapCellsReference object
    "postings"MapPostingsReference object

    Version History

    Introduced in R2011a