KMLWriter

Writes a table of feature data to a text file in KML 2.2 format.

Features

Features are comprised of attributes and geometry. They are defined by the data in an input feature table. The input geometry is indicated by a column named 'geometry'. Features are written as Placemarks to the KML file.

Styles

Styling is generated from either a supplied table of style information, or from style attributes supplied in the feature table. Alternatively, for simplicity features can be styled using styling information supplied as command parameters. StyleMaps are supported, defined by special columns in the style table.

Folders

Placemarks are grouped into folders if the kmlFolderID column is present. Each folder can also be given a kmlFolderName and a kmlFolderVisibility setting. The name is optional; if omitted the folderID is used. In order to be grouped correctly in the output, the feature table must be sorted in order of folderID. This is easily accomplished by using a order by kmlFolderId clause on the statement creating the Placemark data table.

Note that folder attributes are thus specified redundantly in the table. These attributes can be specified directly as column values in the feature table. Alternatively, this can be accomplished cleanly by joining a table containing the feature data (including a kmlFolderId column) to a table containing folder data on the folderId. This is useful if the folder name or description must contain computed data such as summary totals.

Altitude

The geometry of features may carry an altitude value as its Z ordinate, or an altitude value may be provided as a separate column in the feature table. The altitudeMode and extrude flag can also be specified as columns.

Color Values

Color values are specified using the KML aabbggrr format. If the alpha value is missing ff will be used. A leading '#' character is not required. Note that this format is reversed from the common RGB format. (See also the Color.RGBtoBGR function and other functions in that class).

Parameters


(anonymous) Table [Input]
A table containing rows to be written as Placemarks. Each row can contain attribute and geometry data, styling, and folder information, indicated by defined column names.

Styling

Style columns may be supplied directly in the feature table. Any style attribute defined below for the
style table may be used.

Supported columns

Most columns are optional; values will be defaulted or inferred if not supplied.

Column names correspond to the equivalent KML element. The type and allowable values of the column are identical to the type and values of the corresponding KML element, unless indicated otherwise. For detailed information about semantics and element types and values, see the KML Reference.

geometry : Geometry
geometry for the Placemark
kmlName
name of the Placemark
kmlDescription
description of the Placemark
kmlStyleUrl
styleUrl for the Placemark (value should be either a style id or a syleMapId)
kmlAltitude
altitude for the Placemark
kmlAltitudeMode : String
altitude for the Placemark
kmlExtrude : Integer
whether to extrude the Placemark (values must be 0 or 1)
kmlTimeSpanBegin : String
start of the time span for the Placemark
kmlTimeSpanEnd : String
end of the time span for the Placemark
kmlTimeStampWhen : String
time of occurence for the Placemark
kmlFolderId
folder for the Placemark. If present, Placemarks will be grouped into folders based on the value of this id. Feature table must be sorted in order of this column.
kmlFolderName
display name of the folder (optional)
kmlFolderVisibility : Integer
visibility of the folder (0 or 1)

styles: Table [Input]
Provides a table defining the styles to include in the KML file. Each row in the table defines a style. Style attributes are specified as columns with predefined names.

Style Maps

Styles can be grouped into StyleMaps by supplying the optional column styleMapId. If this column is present then the styleMapKey must be present as well. It contains the key value used for the associated style in the map.

Supported columns

All columns are optional.

Column names correspond to the equivalent KML Style element. For detailed information about semantics and element values, see the KML specification for Style and relevant attributes.

Columns marked with an '*' can also be specified as parameters to the command itself. This allows easy specification of constant values, and allows the style map table to be omitted in simple situations. In this case, the style parameter is applied to every feature in the dataset.

id
id for the Style
lineStyleColor *
lineStyleColorMode *
lineStyleWidth *
polyStyleColor *
polyStyleColorMode *
polyStyleFill *
polyStyleOutline *
labelStyleColor *
labelStyleColorMode *
labelStyleScale *
iconStyleColor *
iconStyleColorMode *
iconStyleScale *
iconStyleHref *
styleMapId
id for the StyleMap to contain this style (null if none)
styleMapKey
key for the StyleMap entry for this style (normal or highlight)

addLabelPoint: Boolean [Input]
If true, an interior point is added to each Placemark geometry to support label placement.

comment: String [Input]
string to write as a comment in the KML file.

description: String [Input]
description element for the KML file.

file: String [Input]
pathname of file to write.

name: String [Input]
document name of the KML document.

precision: Integer [Input]
sets the maximum precision (# decimal places) for geometry ordinate values. Useful to decrease the output file size if the input geometry carries a lot of precision and full precision is not needed in the output.

Examples

See here.