Main Content

maprefcells

Reference raster cells to map coordinates

Description

R = maprefcells() returns a default referencing object for a regular raster of cells in planar (map) coordinates.

example

R = maprefcells(xlimits,ylimits,rasterSize) constructs a referencing object for a raster of cells spanning the specified limits in planar coordinates, with the numbers of rows and columns specified by rasterSize.

example

R = maprefcells(xlimits,ylimits,xcellextent,ycellextent) allows the cell extents to be set precisely. If necessary, maprefcells adjusts the limits of the raster slightly to ensure an integer number of cells in each dimension.

example

R = maprefcells(xlimits,ylimits,___,Name,Value) allows the directions of the columns and rows to be specified via name-value pairs.

Examples

collapse all

Define latitude and longitude limits and dimensions of the image. The image follows the popular convention in which world x coordinates increase from column to column and world y coordinates decrease from row to row.

xlimits = [207000 208000];
ylimits = [912500 913000];
rasterSize = [1000 2000]
rasterSize = 1×2

        1000        2000

Create the referencing object specifying the raster size.

R = maprefcells(xlimits,ylimits,rasterSize, ...
    'ColumnsStartFrom','north')
R = 
  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: []


Obtain the same result by specifying the cell extents. For this example, the pixels are 1/2 meter square, referenced to a planar map coordinate system (the "world" system).

extent = 1/2;

R = maprefcells(xlimits,ylimits,extent,extent, ...
    'ColumnsStartFrom','north')
R = 
  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: []


Input Arguments

collapse all

Limits in the x direction, specified as a 1-by-2 numeric vector. The value of xlimits determines the XWorldLimits property of R.

Example: xlimits = [207000 208000];

Limits in the y direction, specified as a 1-by-2 numeric vector. The value of ylimits determines the YWorldLimits property of R.

Example: ylimits = [912500 913000];

Size of the raster, specified as a 1-by-2 numeric vector.

Example: rasterSize = [180 360];

Width of cells, specified as a numeric scalar. The value of xcellextent determines the CellExtentInWorldX property of R.

Example: xcellextent = 1.5

Height of cells, specified as a numeric scalar. The value of ycellextent determines the CellExtentInWorldY property of R.

Example: ycellextent = 1.5

Name-Value Arguments

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: R = maprefcells(latlim,lonlim,rasterSize,'ColumnsStartFrom','north')

Edge from which column indexing starts, specified as 'north' or 'south'.

Example: R = maprefcells(latlim,lonlim,rasterSize,'ColumnsStartFrom','north')

Data Types: char | string

Edge from which column indexing starts, specified as 'west' or 'east'.

Example: R = maprefcells(latlim,lonlim,rasterSize,'RowsStartFrom','east')

Data Types: char | string

Output Arguments

collapse all

Object that references raster cells to map coordinates, returned as a MapCellsReference raster reference object.

Tips

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

Version History

Introduced in R2015b