kml.poly
Create a 2D polygon with vertices given by longitude and latitude.
Contents
Syntax
kml.poly(long, lat, alt) kml.poly(...,'PropertyName',PropertyValue,...)
Description
Creates a 2D polygonal form, with vertices given by longitude and latitude.
The units for latitude and longitude are normally given in degrees, but this can be changed by calling: kml.useDegrees; or kml.useRadians; before plotting.
It is possible to fine tune the polygon properties using name-value pairs:
kml.poly(...,'PropertyName',PropertyValue,...)
Properties
Property Name | Type | Description |
---|---|---|
'name' | string | Name of the polygon in the kml file |
'id' | string | Internal id of this plot inside the kml |
'description' | string | A short description of what the polygon represents |
'visibility' | true/false | Control the initial visibility of the polygon |
'lineColor' | kml color string | Defines the color of the polygon lines. Must be a valid hex color string input, in the style AABBGGRR |
'polyColor' | kml color string | Defines the color of the polygon faces. Must be a valid hex color string input, in the style AABBGGRR |
'lineWidth' | double | Defines the width of the polygon lines. Set to zero to show no lines. |
'altitude' | double | Altitude where the 2D polygon should be plotted. Input in meters. |
'altitudeMode' | string | Choose if the altitude value is absolute to the earth model, relative to the ground level, or should be clamped to the ground. Valid inputs: 'absolute', 'relativeToGround', 'clampToGround' |
'extrude' | true/false | Enables or disables extruding the polygon to the ground. |
'tessellate' | true/false | Tesselates the polygon into the ground, so that it will be visible within the terrain contour |
'timeStamp' | kml date string | Associates the polygon to a moment in time. Should not be used together with timeSpan. Should be a string in the XML time format (more information available here) |
'timeSpanBegin' | kml date string | Defines the moment in time where the polygon starts to exist. Should not be used together with timeStamp. Should be a string in the XML time format (more information available here) |
'timeSpanEnd' | kml date string | Defines the moment in time where the polygon finishes to exist. Should not be used together with timeStamp. Should be a string in the XML time format (more information available here) |
Example
% Create a new kml object k = kml('my kml file'); % Creates a set of cylinders in the kml, at coordinates representing the most populated % cities in the world, with the height of the cylinder proportional to the population. % % Population Data Copyright notice: © by Stefan Helders www.world-gazetteer.com tp = linspace(0,360,20); cities = load('cities.mat'); cities = cities.cities; cmap = jet(20); pops = linspace(min([cities(:).Population]),max([cities(:).Population]),20); for i = 1:numel(cities) color = [interp1(pops,cmap(:,1),cities(i).Population) interp1(pops,cmap(:,2),cities(i).Population) interp1(pops,cmap(:,3),cities(i).Population)]; color = min(max(floor(color*255),0),255); [r,g,b,a] = deal(color(1),color(2),color(3),255); [rhex, ghex, bhex, ahex ]= deal(dec2hex(r),dec2hex(g),dec2hex(b),dec2hex(a)); if length(rhex)==1,rhex=['0' rhex];end if length(ghex)==1,ghex=['0' ghex];end if length(bhex)==1,bhex=['0' bhex];end if length(ahex)==1,ahex=['0' ahex];end colorHex = [ahex bhex ghex rhex]; k.poly(cities(i).Longitude + 0.5*sind(tp),cities(i).Latitude + 0.5*cosd(tp), ... 'altitude',sqrt(cities(i).Population)*5e2,... 'altitudeMode','relativeToGround', ... 'extrude',true,... 'name',[cities(i).Name '[' cities(i).Country ']'],... 'lineWidth',0,... 'polyColor',colorHex); end % Save the kml and open it in Google Earth k.run;
This is the result of running this example:

This file is part of the kml toolbox. Copyright 2012 Rafael Fernandes de Oliveira (rafael@rafael.aero)