Main Content

mapcrop

Crop projected map raster

Since R2020a

Description

example

[B,RB] = mapcrop(A,RA,xlimits,ylimits) crops the projected map raster specified by A and raster reference RA and returns the cropped raster B and raster reference RB. The returned raster is cropped to limits in world coordinates close to those specified by xlimits and ylimits.

To clip vector data represented by a point, line, or polygon shape in planar coordinates, use the mapclip function instead.

Examples

collapse all

Crop a projected raster image and display the cropped image.

First, import a projected raster image of Boston and a map cells reference object. Then, crop the image to the limits specified by xlimits and ylimits.

[A,RA] = readgeoraster("boston.tif");
xlimits = [771660  773290];
ylimits = [2953410 2955240];
[B,RB] = mapcrop(A,RA,xlimits,ylimits);

Display the cropped image.

mapshow(B,RB)

Input Arguments

collapse all

Projected map raster, specified as an M-by-N or M-by-N-by-P numeric or logical array.

Raster reference for A, specified as a MapCellsReference object or MapPostingsReference object. The TransformationType property of RA must be 'rectilinear'.

Minimum and maximum x limits, specified as a two-element numeric vector of the form [xmin xmax], where xmax is greater than xmin.

Minimum and maximum y limits, specified as a two-element numeric vector of the form [ymin ymax], where ymax is greater than ymin.

Output Arguments

collapse all

Cropped projected map raster, returned as a numeric or logical array. The data type and size of B matches the data type and size of A.

If the limits specified by xlimits and ylimits do not intersect the raster specified by A and RA, then B is empty.

Raster reference for B, returned as MapCellsReference object or MapPostingsReference object. The object type of RB matches the object type of RA.

The exact x and y limits of RB do not match the limits specified by xlimits and ylimits, unless they coincide with a cell boundary or posting location. Otherwise, the limits of RB are slightly larger than xlimits and ylimits.

If the limits specified by xlimits and ylimits do not intersect the raster specified by A and RA, then RB is empty.

Version History

Introduced in R2020a