Main Content

mapinterp

Interpolation for planar map raster

Description

Vq = mapinterp(V,R,xq,yq) interpolates the planar map raster V, which uses the raster reference R, at the specified query points. The query points have x-coordinates xq and y-coordinates yq.

example

Vq = mapinterp(___,method) specifies the interpolation method. By default, the function uses bilinear interpolation.

Examples

collapse all

Load elevation data for an area around Mount Washington as an array and a map cells reference object.

[V,R] = readgeoraster("MtWashington-ft.grd",OutputType="double");

Specify the points to interpolate using xy-coordinates. Then, interpolate the values.

xq = [312829 317447 316083 311150];
yq = [4913618 4912253 4904329 4904172];
Vq = mapinterp(V,R,xq,yq)
Vq = 1×4
103 ×

    1.5240    3.6780    6.2363    2.3646

Input Arguments

collapse all

Planar map raster, specified as an M-by-N numeric or logical matrix.

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

x-coordinates of the query points, specified as a numeric array. The sizes of xq and yq must match.

Data Types: single | double

y-coordinates of the query points, specified as a numeric array. The sizes of xq and yq must match.

Data Types: single | double

Interpolation method, specified as one of these options:

  • "linear" — Linear interpolation. The interpolated value at a query point is based on linear interpolation of the values at neighboring points. This method is sometimes called bilinear interpolation.

  • "nearest" — Nearest-neighbor interpolation. The interpolated value at a query point is the value of the nearest point.

  • "cubic" — Cubic interpolation. The interpolated value at a query point is based on cubic interpolation of the values at neighboring points. The interpolation is based on a cubic convolution. This method is sometimes called bicubic interpolation.

  • "spline" — Cubic spline interpolation. The interpolated value at a query point is based on a cubic interpolation of the values at neighboring points. The interpolation is based on a cubic spline using not-a-knot end conditions.

Data Types: char | string

Output Arguments

collapse all

Interpolated values, returned as a numeric array. The number of interpolated values matches the number of query points.

Tips

Interpolate a raster in geographic coordinates by using the geointerp function.

Version History

Introduced in R2017a