Main Content

mapresize

Resize planar map raster

Description

[B,RB] = mapresize(A,RA,scale) resizes the planar map raster A, which uses the raster reference RA, so that the size of B is scale times the size of A.

example

[B,RB] = mapresize(___,method) specifies the interpolation method. By default, the function uses cubic interpolation.

[B,RB] = mapresize(___,Antialiasing=tf) specifies whether to perform antialiasing when shrinking a raster.

Examples

collapse all

Import a sample planar map raster and map cells reference object. Query the size of the raster.

[Z1,R1] = readgeoraster("map_sample.tif");
R1.RasterSize
ans = 1×2

     2     2

Resize the raster. Double the length and width of the raster by specifying the scale as 2. Use nearest neighbor interpolation by specifying the interpolation method.

[Z2,R2] = mapresize(Z1,R1,2,"nearest");
R2.RasterSize
ans = 1×2

     4     4

Read an image of Boston into the workspace as an array and a map cells reference object. Display the image on a map.

[A,R] = readgeoraster("boston.tif");

figure
mapshow(A,R)

Figure contains an axes object. The axes object contains an object of type image.

Resize the data using a scale of 0.05. The height and width of the resized image are each one-twentieth of the original height and width.

[B,RB] = mapresize(A,R,0.05);

Display the resized raster on a new map. Note that the cells in the resized map appear larger than the cells in the original map.

figure
mapshow(B,RB)

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

collapse all

Planar map raster, specified as an M-by-N or M-by-N-by-P numeric or logical array. If the array has more than two dimensions, the function resizes only the first two dimensions.

Raster reference for A, specified as a MapCellsReference object or MapPostingsReference object.

Resize factor, specified as numeric scalar. If scale is in the range [0, 1], then B is smaller than A. If scale is greater than 1, then B is larger than A.

Interpolation method, specified as one of these options:

  • "cubic" — Cubic interpolation. The interpolated value at a query point is a weighted average of points in the nearest 4-by-4 neighborhood. This method is sometimes called bicubic interpolation.

  • "nearest" — Nearest-neighbor interpolation. The interpolated value at a query point is the value of the nearest point. This method is useful for resizing indexed images.

  • "bilinear" — Bilinear interpolation. The interpolated value at a query point is a weighted average of points in the nearest 2-by-2 neighborhood. This method is sometimes called linear interpolation.

Data Types: char | string

Perform antialiasing when shrinking a raster, specified as numeric or logical 1 (true) or 0 (false). The default value depends on the value of method.

  • When method is "nearest", the default is false

  • When method is "bilinear" or "cubic", the default is true.

Output Arguments

collapse all

Resized planar map raster, returned as a numeric or logical array. The data type of B matches the data type of A.

Raster reference for B, returned as a MapCellsReference object or MapPostingsReference object.

When RA and RB are MapCellsReference objects, the limits of RA and RB match when scale divides evenly into the number of cells in each dimension. When RA and RB are MapPostingsReference objects, the limits of RA and RB match when scale divides evenly into the number of samples in each dimension minus one. Otherwise, the mapresize function adjusts the limits of RB by a fraction of the cell extents or sample spacing values.

Tips

  • To resize a raster in geographic coordinates, use the georesize function.

  • Resample a raster by using the mapresample function. Raster resampling is useful for matching the resolutions of related rasters.

Version History

Introduced in R2019a