mapresize

Resize projected raster

Description

example

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

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

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

Examples

collapse all

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

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

     1     2
     3     4

R = 
  MapCellsReference with properties:

            XWorldLimits: [200000 300000]
            YWorldLimits: [200000 300000]
              RasterSize: [2 2]
    RasterInterpretation: 'cells'
        ColumnsStartFrom: 'north'
           RowsStartFrom: 'west'
      CellExtentInWorldX: 50000
      CellExtentInWorldY: 50000
    RasterExtentInWorldX: 100000
    RasterExtentInWorldY: 100000
        XIntrinsicLimits: [0.5 2.5]
        YIntrinsicLimits: [0.5 2.5]
      TransformationType: 'rectilinear'
    CoordinateSystemType: 'planar'


Resize the raster using the mapresize function. As input arguments, specify the input raster, the raster referencing object associated with the input raster, and the desired scale of the output raster. This example also specifies the nearest neighbor interpolation method. The function returns the resized raster and a map raster reference object associated with the output raster.

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

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

R2 = 
  MapCellsReference with properties:

            XWorldLimits: [200000 300000]
            YWorldLimits: [200000 300000]
              RasterSize: [4 4]
    RasterInterpretation: 'cells'
        ColumnsStartFrom: 'north'
           RowsStartFrom: 'west'
      CellExtentInWorldX: 25000
      CellExtentInWorldY: 25000
    RasterExtentInWorldX: 100000
    RasterExtentInWorldY: 100000
        XIntrinsicLimits: [0.5 4.5]
        YIntrinsicLimits: [0.5 4.5]
      TransformationType: 'rectilinear'
    CoordinateSystemType: 'planar'


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 CellExtentInWorldX and CellExtentInWorldY fields have updated values as well.

This example shows how to resize a projected raster data set.

Read a projected raster data set into the workspace.

[boston,R] = geotiffread('boston.tif');

Display the raster with mapshow.

mapshow(boston,R)

Resize the projected raster data set. For this example, reduce the raster to one sixteenth its original size.

[resizedBoston,resizedR] = mapresize(boston,R,1/16);

Display the resized raster. Note that mapshow 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
mapshow(resizedBoston,resizedR)

Input Arguments

collapse all

Raster to be resized, specified as a numeric or logical array. If A has more than two dimensions, mapresize 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 map raster reference object. To convert a raster matrix into a map raster reference object, use the refmatToMapRasterReference function.

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.

Example: 0.5

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 raster, returned as a map raster reference object.

Tips

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

Introduced in R2019a