geocontourxy
Contour grid in local system with latitude-longitude results
Syntax
Description
[
returns
line and polygon geoshapes containing contour lines and contour fill
polygons, respectively. This function is non-graphical. You can plot
the return values using contourLines
,contourPolygons
]
= geocontourxy(X
,Y
,Z
,lat0
,lon0
,h0
)geoshow
, if desired.
[___] = geocontourxy(___,
specifies
name-value pairs that control aspects of the operation. Parameter
names can be abbreviated and are case-insensitive.Name,Value
)
Examples
Calculate Contour Lines and Polygons for Area Near Hawaii
Define a set of X and Y coordinates and create contour lines and contour polygons.
X = -150000:10000:150000; Y = 0:10000:300000; [xmesh, ymesh] = meshgrid(X/50000, (Y - 150000)/50000); Z = 8 + peaks(xmesh, ymesh); lat0 = dm2degrees([ 21 18]); lon0 = dm2degrees([-157 49]); h0 = 300; levels = 0:2:18; [contourLines, contourPolygons] = geocontourxy(X,Y,Z,lat0,lon0,h0, ... 'LevelList',levels,'XYRotation',120)
contourLines = 8x1 geoshape vector with properties: Collection properties: Geometry: 'line' Metadata: [1x1 struct] Vertex properties: (8 features concatenated with 7 delimiters) Latitude: [21.1171 21.0296 20.9819 20.9814 20.9880 21.0702 21.1122 21.1431 21.1671 21.1630 21.1171 NaN NaN 21.2852 21.2292 21.1388 21.0741 21.0435 20.9764 20.9704 20.9138 20.8759 20.8703 20.8578 20.8929 20.9872 20.9995 21.0984 ... ] (1x329 double) Longitude: [-158.5364 -158.5053 -158.4015 -158.3987 -158.3903 -158.3425 -158.3542 -158.3876 -158.4450 -158.5114 -158.5364 NaN NaN -158.6115 -158.6641 -158.6876 -158.6790 -158.6707 -158.6182 -158.6134 -158.5258 -158.4445 -158.4145 ... ] (1x329 double) Height: [769.9110 771.5545 686.9961 684.5002 672.2181 584.6248 578.2085 599.1402 650.4579 725.7670 769.9110 NaN NaN 833.2872 911.0870 965.8408 977.6917 979.9987 944.4115 941.7802 869.5591 807.3430 780.8316 705.1597 606.5604 ... ] (1x329 double) Feature properties: ContourLevel: [2 4 6 8 10 12 14 16]
contourPolygons = 9x1 geoshape vector with properties: Collection properties: Geometry: 'polygon' Metadata: [1x1 struct] Vertex properties: (9 features concatenated with 8 delimiters) Latitude: [21.1171 21.1630 21.1671 21.1431 21.1122 21.0702 20.9880 20.9814 20.9819 21.0296 21.1171 NaN 21.1171 21.0296 20.9819 20.9814 20.9880 21.0702 21.1122 21.1431 21.1671 21.1630 21.1171 NaN 21.2852 21.3001 21.3087 21.3269 ... ] (1x651 double) Longitude: [-158.5364 -158.5114 -158.4450 -158.3876 -158.3542 -158.3425 -158.3903 -158.3987 -158.4015 -158.5053 -158.5364 NaN -158.5364 -158.5053 -158.4015 -158.3987 -158.3903 -158.3425 -158.3542 -158.3876 -158.4450 -158.5114 ... ] (1x651 double) Height: [769.9110 725.7670 650.4579 599.1402 578.2085 584.6248 672.2181 684.5002 686.9961 771.5545 769.9110 NaN 769.9110 771.5545 686.9961 684.5002 672.2181 584.6248 578.2085 599.1402 650.4579 725.7670 769.9110 NaN 833.2872 ... ] (1x651 double) Feature properties: LowerContourLevel: [0 2 4 6 8 10 12 14 16] UpperContourLevel: [2 4 6 8 10 12 14 16 18]
Display Hawaii on a map, add a marker, and then display the polygons returned by geocontourxy
on the map.
figure usamap([18.5 22.5],[-161 -154]) hawaii = shaperead('usastatehi.shp', 'UseGeoCoords', true,... 'Selector',{@(name) strcmpi(name,'Hawaii'), 'Name'}); geoshow(hawaii) geoshow(lat0,lon0,'DisplayType','point','Marker','o',... 'MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',10) cmap = parula(1 + length(levels)); for k = 1:length(contourPolygons) lat = contourPolygons(k).Latitude; lon = contourPolygons(k).Longitude; geoshow(lat,lon,'Display','polygon', ... 'FaceColor',cmap(k,:),'FaceAlpha',0.5,'EdgeColor','none') end geoshow(contourLines.Latitude,contourLines.Longitude,'Color','black')
Input Arguments
X
— X-component of a mesh that locates each element of Z in a local x-y plane
vector or matrix
X-component of a mesh that locates each element
of Z in a local x-y plane, specified
as a vector or matrix. geocontourxy
assumes that
units are meters unless you provide a Spheroid
input,
in which case the units of your input must match theLengthUnit
property
of the Spheroid
object.
Data Types: single
| double
Y
— Y-component of a mesh that locates each element of Z in a local x-y plane
vector or matrix
Y-component of a mesh that locates each element of Z in
a local x-y plane. specified as a vector or matrix. geocontourxy
assumes
that units are meters unless you provide a Spheroid
input,
in which case the units of your input must match theLengthUnit
property
of the Spheroid
object.
Data Types: single
| double
Z
— Data to be contoured
2-D array
Data to be contoured, specified as a 2-D array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
lat0
— Geodetic latitude of local origin (reference) point
scalar value in units of degrees
Geodetic latitude of local origin (reference) point, specified as a scalar value in units of degrees.
Data Types: single
| double
lon0
— Geodetic longitude of local origin (reference) point
scalar value in units of degrees
Geodetic longitude of local origin (reference) point, specified as a scalar value in units of degrees.
Data Types: single
| double
h0
— Ellipsoidal height of local origin (reference) point
scalar value
Ellipsoidal height of local origin (reference) point, specified
as a scalar value. geocontourxy
assumes that units
are meters unless you provide a Spheroid
input,
in which case the units of your input must match the unit specified
in theLengthUnit
property of the Spheroid
object.
Data Types: single
| double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: [contourLines, contourPolygons] = geocontourxy(X,Y,Z,lat0,lon0,h0,'LevelList',levels,'XYRotation',120)
LevelList
— Contour levels
vector of Z-values
Contour levels, specified as a vector of Z-values. By default,
the geocontourxy
function chooses levels that span
the range of values.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
XYRotation
— Rotation angle of the local x-y system
0 (default) | scalar value in units of degrees
Rotation angle of the local x-y system, measured counterclockwise from the xEast-yNorth system, specified as a scalar value in units of degrees.
Data Types: single
| double
Spheroid
— Reference spheroid
WGS84 reference ellipsoid (default) | referenceEllipsoid
| oblateSpheroid
| referenceSphere
Reference spheroid, specified as a referenceEllipsoid
, oblateSpheroid
,
or referenceSphere
object. Use the constructor
for one of these three classes, or the wgs84Ellipsoid
function,
to construct a Mapping Toolbox spheroid object. (You cannot directly
pass in to geocontourxy
the name of your spheroid.
Instead, pass that name to referenceEllipsoid
or referenceSphere
and
use the resulting object.) By default, geocontourxy
uses
the WGS84 reference ellipsoid with units of meters.
Output Arguments
contourLines
— Contour lines
line geoshape
Contour lines, returned as a line geoshape
with
one element per contour level. Latitude
and Longitude
properties
contain contour line vertices in degrees. The contour level value
of the k-th element is stored in the ContourLevel
feature
property of contourLines(k)
. A third vertex property, Height
,
contains the ellipsoidal height of each vertex. In combination with Latitude
and Longitude
,
it completes the definition of the 3-D location of the contour line
in the plane that contains the local origin and is parallel to the
tangent plane at the origin latitude and longitude.
contourPolygons
— Contour polygons
polygon geoshape
Contour polygons, returned as a polygon geoshape with one element
(contour fill polygon) per contour interval. Latitude
and Longitude
properties
contain the vertices of the contour fill polygons, specified in degrees.
The LowerContourLevel
and UpperContourLevel
properties
of contourPolygons(k)
store the limits of the k-th
contour interval. As in the case of lines, a third vertex property, Height
,
is included.
Version History
Introduced in R2016a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)