Posted by: Sasirekha R
Geographic, Internet, KML, Markup, OGC, Standard
Drilling deeper into KML – OGC Geographic Visualization Standard
KML is an XML grammar used to visualize geographic data in an earth browser such as a 3D virtual globe, and 2D web browser of mobile mapping applications. KML has a tag-based structure with names and attributes used for specific display purposes and a KML instance is processed by web browsers in a way similar to that of HTML or XML.
KML can be used to:
- Annotate the Earth
- Specify icons and labels to identify locations on the surface of the planet
- Create different camera positions to define unique views for KML features
- Define image overlays to attach to the ground or screen
- Define styles to specify KML feature appearance
- Write HTML descriptions of KML features, including hyperlinks and embedded images
- Organize KML features into hierarchies
- Locate and update retrieved KML documents from local or remote network locations
- Define the location and orientation of textured 3D objects
KML uses the W3C XML Schema language to describe the grammar of conformant KML data instances. Conformant KML 2.2 files shall validate against the KML 2.2 schema. As stated in an earlier article, KML encoding uses geodetic longitude, geodetic latitude and altitude as define by the GML Coordinate Reference System (CRS) with identifier LonLat84_5773. The vertical datum is the WGS84 EGM96 Geoid.
A spatial extent of a Placemark is defined by extending the <Geometry> element. The spatial extent can include:
- the location of an anchor point on the earth, that serves as an origin for a 3D object in case of Model element.
- the encoding of explicit coordinate tuples in the coordinates element (as in Point, LineString or LinearRing).
In case of LineString, LinearRing and Polygon elements, subclauses are used to describe the interpolation schemes (used to represent Placemark that are not explicitly encoded).
The interpolation used for LineString and LinearRing depend on the values of the child altitudeMode (relativeToGround, absolute, clampToGround) and tessellate (1-true or 0-false) elements. It is worth noting that the control points of every LinearRing must lie on a common plane. The following KML instance, has the projected LineString that follow the earth’s curvature:
<kml xmlns="http://earth.google.com/kml/2.2"> <Document> <Placemark> <LineString> <tessellate>true</tessellate> <altitudeMode>clampedToGround</altitudeMode> <coordinates>-135,30,500000 -80,30,500000</coordinates> </LineString> </Placemark> </Document> </kml>
The interpolation used for Polygon also depends on the values of the child altitudeMode (relativeToGround, absolute, clampToGround) and tessellate (1-true or 0-false) elements. In the following Polygon instance with the altitudeMode set to clampToGround, translates to a part in the earth’s terrain surface as shown below:
<kml xmlns="http://earth.google.com/kml/2.2"> <Document> <Placemark> <Polygon> <altitudeMode>clampToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <coordinates>-135,78.5,300000 -135,12.5,300000 -45,12.5,300000 -45,78.5,300000 -135,78.5,300000</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Document> </kml>
- The outer boundary points of the polygon that are interpolated between the control points in the LinearRing form a rectangular perimeter in the plate carrée plane.
- Then the interior points of the rectangle are filled in linearly in this plane.
- Finally each (long,lat) point of the rectangle is mapped to a (long,lat,alt) point on the earth terrain surface.
Refer to http://blog.opengeo.org/2010/08/10/shape-of-a-polygon/ for Interesting examples on Polygon and their representation in KML.
Refer to http://code.google.com/apis/kml/documentation/kmlreference.html#polystyle for complete reference – including coloring of Polygons.
For more detailed information on KML models and syntax, the OGC Project document titled “KML 2.2 – An OGC Best Practice” with more details can be downloaded from http://portal.opengeospatial.org/files/?artifact_id=23689.