Main Content

ltln2val

(Removed) Extract data grid values for specified locations

ltln2val has been removed. Use the geointerp function instead. For more information, see Version History.

Syntax

val = ltln2val(Z, R, lat, lon)
val = ltln2val(Z, R, lat, lon, method)

Description

val = ltln2val(Z, R, lat, lon) interpolates a regular data grid Z with referencing vector R at the points specified by vectors of latitude and longitude, lat and lon. 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).

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

[cells/degree northern_latitude_limit western_longitude_limit]

If R is a referencing matrix, it must be 3-by-2 and transform raster row and column indices to or from geographic coordinates according to:

[lon lat] = [row col 1] * R

If 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. Nearest-neighbor interpolation is used by default. NaN is returned for points outside the grid limits or for which lat or lon contain NaN. All angles are in units of degrees.

val = ltln2val(Z, R, lat, lon, method) where method specifies the type of interpolation: 'bilinear' for linear interpolation, 'bicubic' for cubic interpolation, or 'nearest' for nearest neighbor interpolation.

Examples

Load elevation raster data and a geographic cells reference object. Then, find the elevation in meters associated with Milan, Bern, and Prague.

load topo60c
lat = [45.45 46.95 50.1];
lon = [9.2 7.4 14.45];
elevations = ltln2val(topo60c,topo60cR,lat,lon)
elevations =

         313        1660         297

Version History

expand all

R2023b: Removed

Some functions that accept referencing vectors or referencing matrices as input have been removed, including the ltln2val function. Use a geographic reference object and the geointerp function instead. Reference objects have several advantages over referencing vectors and matrices.

  • Unlike referencing vectors and matrices, reference objects have properties that document the size of the associated raster, its geographic limits, and the direction of its rows and columns. For more information about reference object properties, see the GeographicCellsReference and GeographicPostingsReference objects.

  • You can manipulate the limits of geographic rasters associated with reference objects using the geocrop function.

  • You can manipulate the size and resolution of geographic rasters associated with reference objects using the georesize function.

To update your code, first create a reference object for either a raster of cells using the georefcells function or a raster of regularly posted samples using the georefpostings function. Alternatively, convert from a referencing vector or a referencing matrix to a reference object using the refvecToGeoRasterReference or refmatToGeoRasterReference function, respectively.

Then, replace uses of the ltln2val function with the geointerp function according to these patterns. Note that the default method of interpolation for the geointerp function is 'linear' instead of 'nearest'. In addition, replace the interpolation methods of 'bilinear' and 'bicubic' for the ltln2val function with 'linear' and 'cubic' for the geointerp function.

RemovedRecommended
val = ltln2val(Z,R,lat,lon);
val = geointerp(Z,R,lat,lon,'nearest');
val = ltln2val(Z,R,lat,lon,method);
val = geointerp(Z,R,lat,lon,method);

See Also

| |