pyKML Modules

The pyKML library is separated into several modules, based on similar functionality.

pykml.factory

pyKML Factory Module

The pykml.factory module provides objects and functions that can be used to create KML documents element-by-element. The factory module leverages lxml’s ElementMaker factory objects to create KML objects with the appropriate namespace prefixes.

pykml.factory.get_factory_object_name(namespace)[source]

Returns the correct factory object for a given namespace

pykml.factory.write_python_script_for_kml_document(doc)[source]

Generates a python script that will construct a given KML document

pykml.parser

pyKML Parser Module

The pykml.parser module provides functions that can be used to parse KML from a file or remote URL.

class pykml.parser.Schema(schema)[source]

A class representing an XML Schema used to validate KML documents

assertValid(doc)[source]

Asserts that a KML document is valide

The method generates a validation error if the document is not valid when compared to the XML Schema.

validate(doc)[source]

Validates a KML document

This method eturns a boolean value indicating whether the KML document is valid when compared to the XML Schema.

pykml.parser.fromstring(text, schema=None)[source]

Parses a KML text string

This function parses a KML text string and optionally validates it against a provided schema object

pykml.parser.parse(fileobject, schema=None)[source]

Parses a file object

This functon parses a KML file object, and optionally validates it against a provided schema.

pykml.helpers

pyKML Helpers Module

The pykml.helpers module contains ‘helper’ functions that operate on pyKML document objects for accomplishing common tasks.

pykml.helpers.separate_namespace(qname)[source]

Separates the namespace from the element

pykml.helpers.set_max_decimal_places(doc, max_decimals)[source]

Sets the maximum number of decimal places used by KML elements

This method facilitates reducing the file size of a KML document.

pykml.util

pyKML Utility Module

The pykml.utility module provides utility functions that operate on KML documents

pykml.util.count_elements(doc)[source]

Counts the number of times each element is used in a document

Table Of Contents

Previous topic

Misc Examples

This Page