georesize

Resize geographic raster

Description

example

[B,RB] = georesize(A,RA,scale) returns the raster B that is scale times the size of the raster A. RA is a geographic raster reference object that specifies the location and extent of data in A. georesize returns the raster reference object RB that is associated with the returned raster B. By default, georesize uses cubic interpolation.

georesize preserves the limits of the raster. If the scale specified divides evenly into the numbers of cells in each dimension, or the number of samples in each dimension minus 1, the limits of the output are the same as the input. Otherwise, georesize adjusts the output limits by a fraction of the cell extents or sample spacing values.

[B,RB] = georesize(A,RA,latscale,lonscale) returns the raster B that is latscale times the size of A in column (north-south) direction and lonscale times the size of A in the row (east-west) direction.

[B,RB] = georesize(___,method) returns a resized raster where method specifies the interpolation method.

[B,RB] = georesize(___,'Antialiasing',TF) specifies whether to perform antialiasing when shrinking a raster. The default depends on the type of interpolation. For nearest-neighbor interpolation, the default value is false. For all other interpolation methods, the default is true.

Examples

collapse all

This example shows how to resize a small geographic raster using the georesize function. The example also resizes the raster specifying different scales for each dimension.

Read Raster into the Workspace

Read a simple raster into the workspace, with its associated raster reference object.

[Z,R] = geotiffread('raster_sample2.tif')
Z = 2×2

     1     2
     3     4

R = 
  GeographicCellsReference with properties:

             LatitudeLimits: [-90 90]
            LongitudeLimits: [-180 180]
                 RasterSize: [2 2]
       RasterInterpretation: 'cells'
           ColumnsStartFrom: 'north'
              RowsStartFrom: 'west'
       CellExtentInLatitude: 90
      CellExtentInLongitude: 180
     RasterExtentInLatitude: 180
    RasterExtentInLongitude: 360
           XIntrinsicLimits: [0.5 2.5]
           YIntrinsicLimits: [0.5 2.5]
       CoordinateSystemType: 'geographic'
                  AngleUnit: 'degree'


Resize an Input Raster

Resize the raster using the georesize function. As input arguments, specify the input raster and the raster referencing object associated with the input raster: Z and R. In addition, specify the desired scale value. georesize multiplies the number of rows and columns of the input raster by the scale value. Finally, the example also specifies the nearest neighbor interpolation method. The function returns the resized raster, Z2, and a geographic raster reference object, R2, associated with the output raster.

[Z2,R2] = georesize(Z,R,2,'nearest')
Z2 = 4×4

     1     1     2     2
     1     1     2     2
     3     3     4     4
     3     3     4     4

R2 = 
  GeographicCellsReference with properties:

             LatitudeLimits: [-90 90]
            LongitudeLimits: [-180 180]
                 RasterSize: [4 4]
       RasterInterpretation: 'cells'
           ColumnsStartFrom: 'north'
              RowsStartFrom: 'west'
       CellExtentInLatitude: 45
      CellExtentInLongitude: 90
     RasterExtentInLatitude: 180
    RasterExtentInLongitude: 360
           XIntrinsicLimits: [0.5 4.5]
           YIntrinsicLimits: [0.5 4.5]
       CoordinateSystemType: 'geographic'
                  AngleUnit: 'degree'


In the raster reference object associated with the output raster, the RasterSize field is updated to show the new size, 4-by-4. Additionally, the CellExtentInLatitude and CellExtentInLongitude fields have updated values as well. The LatitudeLimits and LongitudeLimits fields remain unchanged.

Specify Different Scale for Each Direction

Resize the input raster specifying different scales in the north-south direction (latscale) and the east-west direction (lonscale).

[Z3,R3] = georesize(Z,R,3,2,'nearest')
Z3 = 6×4

     1     1     2     2
     1     1     2     2
     1     1     2     2
     3     3     4     4
     3     3     4     4
     3     3     4     4

R3 = 
  GeographicCellsReference with properties:

             LatitudeLimits: [-90 90]
            LongitudeLimits: [-180 180]
                 RasterSize: [6 4]
       RasterInterpretation: 'cells'
           ColumnsStartFrom: 'north'
              RowsStartFrom: 'west'
       CellExtentInLatitude: 30
      CellExtentInLongitude: 90
     RasterExtentInLatitude: 180
    RasterExtentInLongitude: 360
           XIntrinsicLimits: [0.5 4.5]
           YIntrinsicLimits: [0.5 6.5]
       CoordinateSystemType: 'geographic'
                  AngleUnit: 'degree'


In the raster reference object associated with the output raster, the RasterSize field reflects the new size.

Load a raster data set showing land elevations and bathymetry for the region around the Korean peninsula, at a resolution of 12 cells per degree. The data includes a raster image, korea5c, and an associated geographic raster reference object, korea5cR.

load korea5c

View the raster data set, using geoshow, specifying the associated raster reference object.

geoshow(korea5c,korea5cR,'DisplayType','texturemap')

Resize the raster to be a quarter of its original size.

[resizedKorea,resizedKoreaR] = georesize(korea5c,korea5cR,0.25);

View the resized raster. Note that geoshow preserves the original limits of the map in the display so that, at first glance, the resized raster appears to be the same size as the original. A closer look reveals that the size of pixels in the resized raster are larger than the pixels in the original.

figure
geoshow(resizedKorea,resizedKoreaR,'DisplayType','texturemap')

Input Arguments

collapse all

Raster to be resized, specified as a numeric or logical array. If A has more than two dimensions, such as with a color raster in RGB format, georesize only resizes the first two dimensions.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Information about location and extent of raster, specified as a raster reference object. To convert a referencing vector or referencing matrix into a raster reference object, use the refvecToGeoRasterReference or refmatToGeoRasterReference.

Amount of resizing, specified as numeric scalar. If scale is in the range [0 1], B is smaller than A. If scale is greater than 1, B is larger than A.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Amount of resizing in north-south direction, specified as numeric scalar. If latscale is in the range [0 1], B is smaller than A. If latscale is greater than 1, B is larger than A.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Amount of resizing in east-west direction, specified as numeric scalar. If lonscale is in the range [0 1], B is smaller than A. If lonscale is greater than 1, B is larger than A.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Interpolation method, specified as one of the following values:

ValueDescription
'nearest'Nearest-neighbor interpolation
'bilinear'Bilinear interpolation
'cubic'Cubic interpolation

Data Types: char | string

Output Arguments

collapse all

Resized raster, returned as a numeric or logical array.

Information about location and extent of the raster, returned as a geographic raster reference object.

Tips

  • Use georesize with raster data in latitude and longitude coordinates. To work with projected raster data, in x- and y-coordinates, use mapresize.

Introduced in R2019a