Main Content

refvecToGeoRasterReference

Convert referencing vector to geographic raster reference object

    Description

    Create Reference Object

    example

    R = refvecToGeoRasterReference(refvec,rasterSize) converts the referencing vector refvec into a reference object for a raster of cells referenced to geographic coordinates, using the raster size rasterSize.

    Note

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

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

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

    Validate Inputs

    R = refvecToGeoRasterReference(___,funcName), when refvec 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 vector. For more information about validating inputs, see the validateattributes function.

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

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

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

    Examples

    collapse all

    Specify a referencing vector for a 180-by-240 grid that contains 12 cells per degree for an area around the Korean Peninsula. Then, convert the referencing vector to a geographic raster reference object.

    refvec = [12 45 115];
    rasterSize = [180 240];
    R = refvecToGeoRasterReference(refvec,rasterSize)
    R = 
      GeographicCellsReference with properties:
    
                 LatitudeLimits: [30 45]
                LongitudeLimits: [115 135]
                     RasterSize: [180 240]
           RasterInterpretation: 'cells'
               ColumnsStartFrom: 'south'
                  RowsStartFrom: 'west'
           CellExtentInLatitude: 1/12
          CellExtentInLongitude: 1/12
         RasterExtentInLatitude: 15
        RasterExtentInLongitude: 20
               XIntrinsicLimits: [0.5 240.5]
               YIntrinsicLimits: [0.5 180.5]
           CoordinateSystemType: 'geographic'
                  GeographicCRS: []
                      AngleUnit: 'degree'
    
    
    

    For comparison, create an equivalent reference object directly by using the georefcells function.

    R2 = georefcells([30 45],[115 135],rasterSize)
    R2 = 
      GeographicCellsReference with properties:
    
                 LatitudeLimits: [30 45]
                LongitudeLimits: [115 135]
                     RasterSize: [180 240]
           RasterInterpretation: 'cells'
               ColumnsStartFrom: 'south'
                  RowsStartFrom: 'west'
           CellExtentInLatitude: 1/12
          CellExtentInLongitude: 1/12
         RasterExtentInLatitude: 15
        RasterExtentInLongitude: 20
               XIntrinsicLimits: [0.5 240.5]
               YIntrinsicLimits: [0.5 180.5]
           CoordinateSystemType: 'geographic'
                  GeographicCRS: []
                      AngleUnit: 'degree'
    
    
    

    Input Arguments

    collapse all

    Referencing vector, specified as a three-element vector such that:

    • 1/refvec(1) specifies the extent of individual raster cells in latitude and longitude.

    • refvec(2) specifies the latitude of the northwest corner of the raster.

    • refvec(3) specifies the longitude of the northwest corner of the raster.

    When combined with rasterSize, the referencing vector must create valid latitude and longitude limits.

    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 refvecToGeoRasterReference function uses only the first two elements of the size vector.

    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 refvecToGeoRasterReference 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 refvecToGeoRasterReference function ignores the varName input.

    Data Types: char | string

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

    Data Types: double

    Geographic raster reference object, specified as a GeographicCellsReference or GeographicPostingsReference object.

    Output Arguments

    collapse all

    Geographic raster reference object, returned as a GeographicCellsReference or GeographicPostingsReference object.

    The refvecToGeoRasterReference function returns a GeographicPostingsReference object only when you specify Rin as a GeographicPostingsReference object. Otherwise, the function returns a GeographicCellsReference object.

    Version History

    Introduced in R2011a