Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

wmpolygon

Display geographic polygon on web map

Syntax

wmpolygon(lat,lon)
wmpolygon(P)
wmpolygon(wm,___)
wmpolygon(___,Name,Value)
h = wmpolygon(___)

Description

example

wmpolygon(lat,lon) displays the polygon overlay defined by the vertices in lat and lon on the current web map. If there is no current web map, wmpolygon creates one. wmpolygon centers and scales the map so that all the vector overlays displayed in the web map are visible.

example

wmpolygon(P) displays a polygon overlay based on the content of the polygon geoshape vector P. The overlay contains one polygon feature for each element of P.

wmpolygon(wm,___) displays the overlay in the web map specified by the web map handle, wm.

example

wmpolygon(___,Name,Value) specifies name-value pairs that set additional display properties.

h = wmpolygon(___) returns a handle to the overlay.

Examples

collapse all

Load coastline data from a MAT-file.

load coastlines

Display the coast lines as a polygon overlay layer.

wmpolygon(coastlat,coastlon,'OverlayName','Polygon coastlines')

Define coordinates of rings. For this example, the coordinates define a location centered on the Eiffel Tower.

lat0 = 48.858288;
lon0 = 2.294548;
outerRadius = .01;
innerRadius = .005;
[lat1,lon1] = scircle1(lat0,lon0,outerRadius);
[lat2,lon2] = scircle1(lat0,lon0,innerRadius);
lat2 = flipud(lat2);
lon2 = flipud(lon2);
lat = [lat1; NaN; lat2];
lon = [lon1; NaN; lon2];

Display on web map.

webmap('worldimagery')
wmpolygon(lat,lon,'EdgeColor','g','FaceColor','c','FaceAlpha',.5)

Read state boundary data from shapefile in polygon geoshape.

p = shaperead('usastatelo.shp','UseGeoCoords',true);
p = geoshape(p);

Define the colors you want to use for the polygons.

colors = polcmap(length(p));

Display the polygons as an overlay on a web map. The example uses the FaceAlpha parameter to make the polygons semi-transparent.

webmap('worldphysicalmap')
wmpolygon(p,'FaceColor',colors,'FaceAlpha',.5,'EdgeColor','k', ...
      'EdgeAlpha',.5,'OverlayName','USA Boundary','FeatureName',p.Name)

Large data sets can sometimes be slow to display, making the web map browser appear to hang. This example shows how to reduce the size of a data set using reducem before calling wmpolygon.

  1. Load high-resolution vector data into the workspace.

    states = shaperead('usastatehi.shp','UseGeoCoords', true);
    states = geoshape(states);
    
  2. Reduce the number of points in the latitude and longitude vectors using the reducem function.

    for k = 1:length(states)
        [states(k).Latitude, states(k).Longitude] = reducem( ...
            states(k).Latitude', states(k).Longitude');
    end
    
  3. Display state boundaries on the web map. Note that the borders of the reduced polygons may not meet if you zoom in on them.

    colors = polcmap(length(states));
    webmap('worldphysicalmap')
    wmpolygon(states,'FaceColor',colors,'FaceAlpha',.5,'EdgeColor','k', ...
        'EdgeAlpha',.5,'OverlayName','USA Boundary','FeatureName',states.Name)
    

Input Arguments

collapse all

Latitude vertices, specified as matrix in the range [-90, 90].

Data Types: single | double

Longitude of vertices, specified as a matrix.

Data Types: single | double

Geographic features, specified as a polygon geoshape vector.

Web map, specified as a handle to a web map.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: wmpolygon(lat,lon,'Autofit',true)

collapse all

Overlay visibility, specified as the comma-separated pair consisting of 'Autofit' and the scalar logical or numeric value true (1) or false (0).

  • If true, wmpolygon adjusts the spatial extent of the map to ensure that all the vector overlays on the map are visible.

  • If false, wmpolygon does not adjust the spatial extent of the map when this vector layer is added to the map.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Description of feature, specified as the comma-separated pair consisting of 'Description' and a character vector, cell array of character vectors, or a scalar structure.

  • If you specify a character vector, the text defines the content displayed in the description balloon, which appears when you click the feature in the web map. Description elements can be either plain text or marked up with HTML markup.

  • If you specify a cell array, it must be either a scalar or the same length as P, and specifies the description for each polygon.

  • If the value is a structure (attribute specification), wmpolygon displays the attribute fields of P in the balloon, modified according to the specification.

Data Types: char | struct | cell

Name of overlay layer, specified as the comma-separated pair consisting of 'OverlayName' and a character vector. wmpolygon inserts the name in the Layer Manager under the "Overlays" item. The Layer Manager is the tool that appears on the right side of the web map browser. The default name is 'Polygon Overlay N' where N is the number assigned to this overlay.

Data Types: char

Name of feature, specified as the comma-separated pair consisting of 'FeatureName' and character vector or cell array of character vectors. The name appears in the balloon when you click the feature in the web map. The default value is 'OverlayName: Polygon K', where OverlayName is the name of the overlay and K is the number assigned to the particular polygon.

  • If the value is a character vector, it applies to all features.

  • If the value is a cell array of character vectors, it must be either a scalar or the same length as P.

Data Types: char | cell

Color of polygon faces, specified as the comma-separated pair consisting of 'FaceColor' and a MATLAB® Color Specification (ColorSpec), a cell array of color names, or a numeric array. The value 'none' indicates that the polygons are not filled.

  • If the value is a cell array, it must be scalar or the same length as P.

  • If the value is a numeric array, it must be an m-by-3 where m is either 1 or the length of P.

Data Types: double | char | cell

Transparency of polygon faces, specified as the comma-separated pair consisting of 'FaceAlpha' and a numeric scalar or vector in the range [0, 1]. The default value, 1, means that the polygon is fully opaque.

  • If the value is a scalar, it applies to all polygon faces.

  • If the value is a vector, it must be the same length as P.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Color of polygon edges, specified as the comma-separated pair consisting of 'EdgeColor' and a MATLAB Color Specification (ColorSpec), a cell array of color namess, or a numeric array. The value 'none' indicates that the polygons have no edges.

  • If the value is a cell array, it must be scalar or the same length as P.

  • If the value is a numeric array, it must be m-by-3, where m is either 1 or the length of P.

Data Types: double | char | cell

Transparency of polygon edges, specified the comma-separated pair consisting of 'EdgeAlpha' and as a numeric scalar or vector in the range [0, 1].

  • If the value is a scalar, it applies to all polygon faces.

  • If the value is a vector, it must be the same length as P.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Width of polygon edges, specified as the comma-separated pair consisting of 'LineWidth' and a positive numeric scalar or vector.

  • If the value is a scalar, it applies to all polygon faces.

  • If the value is a vector, it must be the same length as P.

Example:

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Polygon overlay, returned as a handle to the polygon overlay.

Tips

  • When you move the cursor over the polygons you define on an image and click, wmpolygon displays a description balloon and disables panning. If you move the cursor off the polygon, you can still click and pan the image. You can also use the arrow keys to pan the image.

See Also

Functions

Using Objects

Introduced in R2016a

Was this topic helpful?