Main Content

georasterref

(Not recommended) Create geographic raster reference object

    The georasterref function is not recommended, except when creating a raster reference object from a world file matrix. To specify options using name-value arguments, use the georefcells or georefpostings function instead. For more information, see Version History.

    Description

    R = georasterref(W,rasterSize) creates a reference object for a raster of quadrangular cells referenced to geographic coordinates using the world file matrix W and raster size rasterSize.

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

    example

    R = georasterref(Name,Value) specifies options using name-value arguments.

    Examples

    collapse all

    Create a reference object for a global raster of cells with size 180-by-360, latitude extents of 1 degree, and longitude extents of 1 degree. Orient the raster using a convention typical for imagery, where image rows run from west to east and image columns run from north to south.

    Specify the world file matrix using these values:

    ValueExplanation
    1The rows of the raster start from the west and each cell is one degree in longitude.
    -179.5The longitude of the first cell center.
    -1The columns of the raster start from the north and each cell is one degree in latitude.
    89.5The latitude of the first cell center.

    W = [1 0 -179.5; 0 -1 89.5];
    

    Create the reference object.

    R = georasterref(W,[180 360],"cells")
    R = 
    
      GeographicCellsReference with properties:
    
                 LatitudeLimits: [-90 90]
                LongitudeLimits: [-180 180]
                     RasterSize: [180 360]
           RasterInterpretation: 'cells'
               ColumnsStartFrom: 'north'
                  RowsStartFrom: 'west'
           CellExtentInLatitude: 1
          CellExtentInLongitude: 1
         RasterExtentInLatitude: 180
        RasterExtentInLongitude: 360
               XIntrinsicLimits: [0.5 360.5]
               YIntrinsicLimits: [0.5 180.5]
           CoordinateSystemType: 'geographic'
                  GeographicCRS: []
                      AngleUnit: 'degree'

    Input Arguments

    collapse all

    World file matrix, specified as a 2-by-3 numeric array of the form [lonspacing 0 lon; 0 latspacing lat], where:

    • lonspacing determines the RowsStartFrom and the CellExtentInLongitude or SampleSpacingInLongitude properties of R.

      • When lonspacing is positive, RowsStartFrom is 'west'. When lonspacing is negative, RowsStartFrom is 'east'.

      • CellExtentInLongitude or SampleSpacingInLongitude is abs(lonspacing).

    • latspacing determines the ColumnsStartFrom and the CellExtentInLatitude or SampleSpacingInLatitude properties of R.

      • When latspacing is positive, ColumnsStartFrom is 'south'. When latspacing is negative, ColumnsStartFrom is 'north'.

      • CellExtentInLatitude or SampleSpacingInLatitude is abs(latspacing).

    • lat and lon are the latitude and longitude coordinates of the first cell center or posting point, respectively. For a spatially referenced raster A, the first cell center or posting point is the spatial location associated with A(1,1,:).

    • The 0 values indicate a rectilinear relationship between the intrinsic and geographic coordinates.

    A world file matrix defines a transformation that maps intrinsic coordinates to geographic coordinates.

    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 georasterref 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 property of the reference object, RasterInterpretation, is read-only after you create the object.

    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: georasterref("LatitudeLimits",[-90 90],"LongitudeLimits",[-180 180]) creates a geographic cells reference object with latitudes in the range [–90, 90] degrees and longitudes in the range [–180, 180] degrees.

    Latitude limits of the geographic quadrangle that bounds the georeferenced raster, specified as a two-element vector of the form [southern_limit northern_limit].

    Longitude limits of the geographic quadrangle that bounds the georeferenced raster, specified as a two-element vector of the form [western_limit eastern_limit].

    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 RasterSize as a vector with more than two elements, such as the size of an RGB image (m-by-n-by-3). The georasterref 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 property of the raster reference object is read-only after you create the object.

    Data Types: char | string

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

    Data Types: char | string

    Edge from which row indexing starts, specified as "west" or "east".

    Data Types: char | string

    Output Arguments

    collapse all

    Geographic raster reference object, returned as a GeographicCellsReference or GeographicPostingsReference object. The value of R depends on the value of the rasterInterpretation argument or RasterInterpretation name-value argument.

    rasterInterpretation or RasterInterpretationR
    "cells"GeographicCellsReference object
    "postings"GeographicPostingsReference object

    Version History

    Introduced in R2011a

    collapse all

    R2015b: georasterref is not recommended

    The georasterref function is not recommended, except when creating a reference object from a world file matrix. To specify options using name-value arguments, use the georefcells or georefpostings function instead.

    • Create a reference object for a grid of quadrangular cells referenced to geographic latitude and longitude coordinates by using the georefcells function.

    • Create a reference object for a grid of posting point samples referenced to geographic coordinates by using the georefpostings function.