Main Content

georesize

Resize geographic raster

Description

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

example

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

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

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

Examples

collapse all

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

[Z1,R1] = readgeoraster("raster_sample2.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] = georesize(Z1,R1,2,"nearest");
R2.RasterSize
ans = 1×2

     4     4

Resize the input raster by specifying different scales for the north-south and east-west directions.

[Z3,R3] = georesize(Z1,R1,3,2,"nearest");
R3.RasterSize
ans = 1×2

     6     4

Load elevation data for the Korean peninsula as an array and a geographic cells reference object. Display the data on a map.

load korea5c

figure
worldmap(korea5c,korea5cR)
geoshow(korea5c,korea5cR,DisplayType="texturemap")

Figure contains an axes object. The hidden axes object contains 13 objects of type patch, surface, line, text.

Resize the data using a scale of 0.25. The height and width of the resized array are each a quarter of the original height and width.

[B,RB] = georesize(korea5c,korea5cR,0.25);

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
worldmap(B,RB)
geoshow(B,RB,DisplayType="texturemap")

Figure contains an axes object. The hidden axes object contains 13 objects of type patch, surface, line, text.

Input Arguments

collapse all

Geographic 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 GeographicCellsReference object or GeographicPostingsReference 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.

Resize factor in the north-south direction, specified as a numeric scalar. If latscale is in the range [0, 1], then B has fewer columns than A. If latscale is greater than 1, then B has more columns than A.

Resize factor in the east-west direction, specified as a numeric scalar. If lonscale is in the range [0, 1], then B has fewer rows than A. If lonscale is greater than 1, then B has more rows 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 geographic 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 GeographicCellsReference object or GeographicPostingsReference object.

When RA and RB are GeographicCellsReference 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 GeographicPostingsReference objects, the limits of RA and RB match when scale divides evenly into the number of samples in each dimension minus one. Otherwise, the georesize function adjusts the limits of RB by a fraction of the cell extents or sample spacing values.

Tips

  • To resize a raster in planar map coordinates, use the mapresize function.

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

Version History

Introduced in R2019a