Version 17 (modified by mkochan, 12 years ago) (diff)


The NERC Portals project

Since it's inception the NERC Portals project has started to be called the Data Portals Prototype Project (DPPP) across the participating institutions.


Conversion from CSML to KML

User manual

Since CSML currently lacks the constructs for describing the context for the CSML features, the actual mechanisms used to convert data from CSML to KML do use limited amount of CSML as a data source. The rest comes from different languages derived from GML. Hence this project became rather a demonstration of how OGC web services can be integrated into a common framework, which has a potential of working using purely CSML data, once CSML matures enough to contain all information in it.

The functionality is split into two eggs:

  • csml2kml - provides static functionality, with the output being KML stored in files (*.kml, *.kmz),
  • csml2kmlpylon - is a web server (to be run by the BADC) providing web services which brings dynamic content to the viewing experience in Google Earth via HTTP.


Usage of the csml2kml scripts

The script

Run this script as:

python filename.conf.xml

where filename.conf.xml stands for an XML config file.

The script interrogates a WMS web service using the GetCapabilities call and thus acquires a <wms:Capabilities> XML document from it, which contains description of WMS layers served by the WMS web service. Then, it exports this into a hierarchy of embedded directories forming a structure which contains a hierarchy of expandable KMZ documents linked together using the <kml:NetworkLink> tag, and loaded on demand. The files can then be served to the outer world via HTTP.

An example format of the config file is as follows (example config files can be found in the egg's csml2kml/config sub-directory):


The field URL is a base URL of the WMS web service serving the intended dataset.

The script

Run this script as:

python filename.conf.xml

where filename.conf.xml stands for an XML config file.

This script interrogates a WFS to get a list of (meteorological) stations, recorded using an element <np:Station> defined for the purposes of this project. It generates a KMZ file that contains a number of <kml:Placemark> elements, each standing for a single station. Each station has has a balloon filled according to a defined template, which refers to a URL of the running csml2kmlpylon Pylon. Thus dynamic content about each station can be presented.

An example config file looks as follows:

  <DocumentName>MIDAS stations (first 100 of them)</DocumentName>
  <BalloonTemplate>&lt;h2&gt;Station $[station_name]&lt;/h2&gt;Click here to see the list of &lt;a href=&quot;$[station_name]&quot;&gt;CSML features associated with this station&lt;/a&gt; (this will open a window of your default web browser).</BalloonTemplate>
    <Datum name="station_id">#ID#</Datum>
    <Datum name="station_name">#NAME#</Datum>

The non-obvious settings are as follows:

  • UseRegions - determines whether to use embedding into regions.
    • If set to no, stations will be recorded simply as a list of KML placemarks, and will be visible from all altitudes. May cause slow rendering for large number of placemarks.
    • If set to yes, stations will be divided by recursively splitting the the covered are into 4 smaller KML regions. The actual station KML placemarks will be placed at the bottom of the hierarchy. Therefore, they will be forced to be visible only for closer zooms onto the ground, so rendering will be quick.

Deployment of the csml2kmlpylon server

Code notes

Code notes towards csml2kml

The egg's {{{csml2kml} directory contains all Python modules, and the following 4 sub-directories:

  • scripts - contains Python stand-alone scripts, runnable from command line, which both use a config file as a means of input
  • tests - contains tests, which simply print output (rather than fail/pass messages), and are runnable as python, but please look at the contents first to see what the test does
  • config - a preferred location for config files for the scripts, in XML format, which define locations of used Web services etc.
  • output - empty after installation, optionally usable for output of scripts and tests

The modules

There is a naming convention that wrappers of entities which normally exist as XML elements are prefixed with XML spacename. For instance, a class WMSLayer is a wrapper for an element <wms:Layer>. Wrappers for KML elements (in kml namespace), which are used for output, contain a build() method, which builds each instance into an ElementTree.Element object. On the contrary, wrappers for elements in wms and np namespaces contain parseXML() method, as they are used for input.

Code notes towards csml2kmlpylon