Building Sensor Network Interfaces with KML

In the Fall of 2005, I was challenged to create a unified visualization interface to the micro-climate sensor and multimedia networks at the James Reserve. Having already developed some web-based graphing tools for sensor data visualization, I was eager to start add a spatial dimension to diverse sensor deployments.


screen shots from the James Reserve KML layer

The James Reserve KML layer has received rave reviews, even catching the attention of Google's own Vinton Cerf at our grant's External Advisory Board meeting this past January. Dr. Cerf helped to arrange a visit to Google's office in Mountain View, where I demonstrated the project during an Urban Sensing Tech Talk given by a group of us from the Center for Embedded Network Sensing (CENS).

During that trip, I also had the opportunity to show it directly to several members of the Google Earth Team. Having kept in contact with Rebecca Moore ever since, I have been able to send some KML recommendations to the GE team, and share some of my KML ideas and side-projects.

Since my visit to Google earlier this year, I have presented the James Reserve KML layer to great interest at numerous functions, including:

 

Download the layer:

This layer is quite complex, and without an introduction to the sensor systems at the James Reserve, it might be a bit daunting.

If it's a little too much to consume without some guiding explanation, check out the Movies section for an easier look at the layer.

Four flavors available:

 

About James Reserve Sensor Networks

The James Reserve, in Southern California's San Jacinto Mountains, is the field test-bed for the Center for Embedded Network Sensing. There are nearly a dozen independent research projects (2) (3) and accompanying sensor system deployments at the Reserve. In total they comprise of more than 50 webcams and more than 500 stationary and mobile sensors at over 60 locations. Over the next 6 years, the number of sensors at the James Reserve will increase exponentially, as we become the technology proving grounds for the entire National Ecological Observatory Network (NEON).

 

Short list of the KML layer's features:

 

Some details about the KML PHP script :

My PHP scripts can be easily tuned to output several different KML options:


some screen shots of the KML 2.0 version of the layer

 

PHP class for KML generation:

In order to efficiently generate KML, I recently wrote a small OO PHP class that validates KML schema relationships and tag values. This idea was originally inspired by the now abandoned work of TJ1, a once active member of the Keyhole BBS. Though TJ's work was quite complex and full-featured, several problems were beyond my repair and it only supported KML 2.0. Thus I decided to write my own class. Though not as glorious and 'professional' as TJ's promised to be, it has served me quite well.

Here is the source code for the php class.

KmlClass usage:


<?php

include_once("kml_class4.php");

/*

When creating a new KML element, all the required
children must be included at instantiation.

Optional Children can included afterwards

*/
 
$doc = new KmlClass(
		'#create root <document> element', //internal name or comment
		'Document', //KML tag name
		array('name' => 'My kml Layer'), //array of child tags: 'child tag' => 'value'
		array('id' => 'documentId') //'tag attrib' => 'value'
		);

$coords = '-116, -30, 0';

$pt = new KmlClass(
		'#coordinates for my house', 
		'Point',
		 array(
			'coordinates' => $coords,
			'altitudeMode' => 'relativeToGround'
			)
		);

$pl = new KmlClass(
		'#my house',
		'Placemark', 
array( 'name' => 'Home',
'Snippet' => '',
'visibility' => 0,
'styleUrl' => '#myStyle',
'Point' => $pt,
'description' => 'Here is the house I grew up in...') ); $doc->appendChild( array('Placemark' => $pl) ); /* You can also pass in an array of Points/KML tags if they are allowed to occur multiple times $doc->appendChild( array('Placemark' => array($pl, $pl2, $pl3)) ); */ $kml_output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $kml_output = '<kml xmlns="http://earth.google.com/kml/2.0">' . "\n";
generate_kml($kml_output, $doc); //Global function from kml_classX.php
$kml_output .= '</kml>'; echo $kml_output; ?>

 

KML output:

<kml xmlns="http://earth.google.com/kml/2.0">
<Document id="documentId">
<name>My kml Layer</name>
<Placemark>
<name>Home</name>
<Snippet></Snippet>
<visibility>0</visibility>
<styleUrl>#myStyle</styleUrl> <Point>
<coordinates>-116, -30, 0</coordinates>
<altitudeMode>relativeToGround</altitudeMode>
</Point>
<description>Here is the house I grew up in...</description>
</Placemark>
</Document> </kml>