Trim regular data grid to latitude-longitude quadrangle

`[Z_trimmed] = maptrims(Z,R,latlim,lonlim)`

[Z_trimmed] = maptrims(Z,R,latlim,lonlim,cellDensity)

[Z_trimmed, R_trimmed] = maptrims(...)

`[Z_trimmed] = maptrims(Z,R,latlim,lonlim)`

trims
a regular data grid `Z`

to the region specified by `latlim`

and `lonlim`

.
By default, the output grid `Z_trimmed`

has the same
sample size as the input. `R`

can be a geographic
raster reference object, a referencing vector, or a referencing matrix.
If `R`

is a geographic raster reference object, its `RasterSize`

property
must be consistent with `size(Z)`

and its `RasterInterpretation`

must
be `'cells'`

.

If `R`

is a referencing vector, it must be
a 1-by-3 vector with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

`R`

is
a referencing matrix, it must be 3-by-2 and transform raster row and
column indices to/from geographic coordinates according to:
[lon lat] = [row col 1] * R

`R`

is
a referencing matrix, it must define a (non-rotational, non-skewed)
relationship in which each column of the data grid falls along a meridian
and each row falls along a parallel. `latlim`

and `lonlim`

are
two-element vectors, defining the latitude and longitude limits, respectively.
The `latlim`

vector has the form:[southern_limit northern_limit]

Likewise, the `lonlim`

vector has the form:

[western_limit eastern_limit]

When an individual value in `latlim`

or `lonlim`

corresponds
to a parallel or meridian that runs precisely along cell boundaries,
the output grid will extend all the way to that limit. But if a limiting
parallel or meridian cuts through a column or row of input cells,
then the limit will be adjusted inward. In other words, the requested
limits will be truncated as necessary to avoid partial cells.

`[Z_trimmed] = maptrims(Z,R,latlim,lonlim,cellDensity)`

uses
the scalar `cellDensity`

to reduce the size of the
output. If `R`

is a referencing vector, then `R(1)`

must
be evenly divisible by `cellDensity`

. If `R`

is
a referencing matrix, then the inverse of each element in the first
two rows (containing "`deltaLat`

" and "`deltaLon`

")
must be evenly divisible by `cellDensity`

.

`[Z_trimmed, R_trimmed] = maptrims(...)`

returns
a referencing vector, matrix, or object for the trimmed data grid.
If `R`

is a referencing vector, then `R_trimmed`

is
a referencing vector. If `R`

is a referencing matrix,
then `R_trimmed`

is a referencing matrix. If `R`

is
a geographic raster reference object, then `R_trimmed`

is
either a geographic raster reference object (when `Z_trimmed`

is
non-empty) or `[]`

(when `Z_trimmed`

is
empty).

load topo [subgrid,subrefvec] = maptrims(topo,topolegend,... [80.25 85.3],[165.2 170.7]) subgrid = -2826 -2810 -2802 -2793 -2915 -2913 -2905 -2884 -3192 -3186 -3165 -3122 -3399 -3324 -3273 -3214 subrefvec = 1 85 166

The upper left corner of the grid might differ slightly from
that of the requested region. `maptrims`

uses the
corner coordinates of the first cell inside the limits.

Was this topic helpful?