Main Content

geoquadpt

Geographic quadrangle bounding scattered points

Description

[latlim,lonlim] = geoquadpt(lat,lon) returns the limits of the tightest possible geographic quadrangle that bounds a set of points with geographic coordinates lat and lon.

In most cases, tf = ingeoquad(lat,lon,latlim,lonlim) will return true, but tf may be false for points on the edges of the quadrangle, due to round off. tf will also be false for elements of lat that fall outside the interval [-90 90] and elements of lon that are not finite.

example

Examples

collapse all

In this case the output quadrangle straddles the 180-degree meridian, hence the elements of lonlim are in descending numerical order, although they are ordered from west to east.

Read a set of points and then create a bounding box around the points.

cities = shaperead('worldcities.shp','Selector', ...
    {@(name) any(strcmp(name,{'Tokyo','Honolulu'})),'Name'}, ...
    'UseGeoCoords',true);
[latlim,lonlim] = geoquadpt([cities.Lat],[cities.Lon])
latlim =

   21.3178   35.7082


lonlim =

  139.6401 -157.8291

Input Arguments

collapse all

Point latitudes, specified as a vector, matrix, or N-D array, in units of degrees.

Data Types: single | double

Point longitudes, specified as a vector, matrix, or N-D array, in units of degrees.

Data Types: single | double

Output Arguments

collapse all

Latitude limits of a geographic quadrangle, returned as a 1-by-2 vector of the form [southern_limit northern_limit], in units of degrees. The elements are in ascending order, and both lie in the closed interval [-90 90].

Longitude limits of a geographic quadrangle, returned as a 1-by-2 vector of the form [western_limit eastern_limit], in units of degrees. The limits are wrapped to the interval [-180 180]. They are not necessarily in numerical ascending order.

Version History

Introduced in R2012b