Contenido principal

maprefcells

R2026b

Reference raster cells to map coordinates

Description

R = maprefcells(xlimits,ylimits,rasterSize) creates a reference object for a regular raster of cells in planar coordinates. Specify the xy-limits of the raster using xlimits and ylimits. Specify the number of rows and columns in the raster using rasterSize.

example

R = maprefcells(xlimits,ylimits,xcellextent,ycellextent) specifies the width and height of each cell using xcellextent and ycellextent. If necessary, the maprefcells function adjusts the xy-limits to ensure that each dimension of the raster has an integer number of cells.

example

R = maprefcells(___,Name=Value) specifies properties of the reference object using one or more name-value arguments, in addition to the input arguments in the previous syntaxes.

example

Examples

collapse all

Create a reference object for a raster of cells, where the first cell is in the northwest corner. Specify the xy-limits using world coordinates. Specify the projected CRS as NAD83 / Massachusetts Mainland, which has the EPSG authority code 26986.

xlimits = [207000 208000];
ylimits = [912500 913000];
rasterSize = [1000 2000];
pcrs = projcrs(26986);

R1 = maprefcells(xlimits,ylimits,rasterSize, ...
    ColumnsStartFrom="north",ProjectedCRS=pcrs)
R1 = 
  MapCellsReference with properties:

            XWorldLimits: [207000 208000]
            YWorldLimits: [912500 913000]
              RasterSize: [1000 2000]
    RasterInterpretation: 'cells'
        ColumnsStartFrom: 'north'
           RowsStartFrom: 'west'
      CellExtentInWorldX: 1/2
      CellExtentInWorldY: 1/2
    RasterExtentInWorldX: 1000
    RasterExtentInWorldY: 500
        XIntrinsicLimits: [0.5 2000.5]
        YIntrinsicLimits: [0.5 1000.5]
      TransformationType: 'rectilinear'
    CoordinateSystemType: 'planar'
            ProjectedCRS: [1×1 projcrs]


Alternatively, specify the cell extents instead of the raster size.

extent = 1/2;
R2 = maprefcells(xlimits,ylimits,extent,extent, ...
    ColumnsStartFrom="north",ProjectedCRS=pcrs)
R2 = 
  MapCellsReference with properties:

            XWorldLimits: [207000 208000]
            YWorldLimits: [912500 913000]
              RasterSize: [1000 2000]
    RasterInterpretation: 'cells'
        ColumnsStartFrom: 'north'
           RowsStartFrom: 'west'
      CellExtentInWorldX: 1/2
      CellExtentInWorldY: 1/2
    RasterExtentInWorldX: 1000
    RasterExtentInWorldY: 500
        XIntrinsicLimits: [0.5 2000.5]
        YIntrinsicLimits: [0.5 1000.5]
      TransformationType: 'rectilinear'
    CoordinateSystemType: 'planar'
            ProjectedCRS: [1×1 projcrs]


Input Arguments

collapse all

x-limits of the rectangle that bounds the raster, in world coordinates, specified as a two-element vector of the form [xmin xmax], where xmax is greater than xmin.

y-limits of the rectangle that bounds the raster, in world coordinates, specified as a two-element vector of the form [ymin ymax], where ymax is greater than ymin.

Number of rows and columns in 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. This argument sets the RasterSize property of R.

Width of each cell, in world coordinates, specified as a positive scalar. This argument sets the CellExtentInWorldX property of R.

Height of each cell, in world coordinates, specified as a positive scalar. This argument sets the CellExtentInWorldY property of R.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: R = maprefcells(xlimits,ylimits,rasterSize,ColumnsStartFrom="north") creates a map cells reference object with columns that start from north.

Edge from which column indexing starts, specified as one of these options:

  • "south" — Column indexing starts from south.

  • "north" — Column indexing starts from north.

Edge from which row indexing starts, specified as one of these options:

  • "west" — Row indexing starts from west.

  • "east" — Row indexing starts from east.

Projected coordinate reference system (CRS), specified as a projcrs object.

Output Arguments

collapse all

Map cells reference object, returned as a MapCellsReference object.

Tips

To create a map raster reference object from a world file matrix, use the maprasterref function.

Version History

Introduced in R2015b

expand all