Main Content

intrplat

Interpolate latitude at given longitude

Syntax

newlat = intrplat(long,lat,newlong)
newlat = intrplat(long,lat,newlong,method)
newlat = intrplat(long,lat,newlong,method,units)

Description

newlat = intrplat(long,lat,newlong) returns an interpolated latitude, newlat, corresponding to a longitude newlong. long must be a monotonic vector of longitude values. The actual entries must be monotonic; that is, the longitude vector [350 357 3 10] is not allowed even though the geographic direction is unchanged (use [350 357 363 370] instead). lat is a vector of the latitude values paired with each entry in long.

newlat = intrplat(long,lat,newlong,method) specifies the method of interpolation employed, listed in the table below.

MethodDescription
'linear'Linear, or Cartesian, interpolation (default)
'pchip'Piecewise cubic Hermite interpolation
'rh'Returns interpolated points that lie on rhumb lines between input data
'gc'Returns interpolated points that lie on great circles between input data

newlat = intrplat(long,lat,newlong,method,units) specifies the units used, where units is any valid angle units string scalar or character vector. The default is 'degrees'.

The function intrplat is a geographic data analogy of the standard MATLAB® function interp1.

Examples

collapse all

Define the latitudes and longitudes.

lat = [57 68 60 65 56];
lon = [1 3 4 9 13];

Specify the longitude for which you want to compute a latitude.

newlon = 7.3;

Linear Interpolation

Generate a new latitude using the default method of linear interpolation.

newlatLinear = intrplat(lon,lat,newlon)
newlatLinear = 63.3000

Great Circle Interpolation

Generate a new latitude using great circle interpolation.

newlatGC = intrplat(lon,lat,newlon,'gc')
newlatGC = 63.5029

Rhumb Line Interpolation

Generate a new latitude using interpolation along a rhumb line.

newlatRhumb = intrplat(lon,lat,newlon,'rh')
newlatRhumb = 63.3937

Tips

There are separate functions for interpolating latitudes and longitudes, for although the cases are identical when using those methods supported by interp1, when latitudes and longitudes are treated like the spherical angles they are (using 'rh' or 'gc'), the results are different. Compare the example above to the example under intrplon, which reverses the values of latitude and longitude.

Version History

Introduced before R2006a