We have established that
KML
provides plenty of scope for cartography, but need to consider the ways in which
Google Earth
interprets the
KML
and provides access to the features that we are mapping. Doing so allows us to take advantage of some of the interactive
and dynamic capabilities of
Google Earth
and generate
KML
that is particularly appropriate for visualization.
The 'Places' window in
Google Earth
is the key here. It allows us to select
KML
files and importantly file sections from the
XML
hierarchy. Two
KML
elements are particularly significant in this context : Document and Folder.
These two elements act as 'containers' into which data may be structured. They can both be associated with name and description elements that provide labels for the containers in the 'Places' window. These are children of the Document and Folder elements and should be placed within them. Document and Folder elements can be arranged hierarchically and the 'Places' interface used to select branches of the hierarchical tree for display
: any Placemark or other feature is only shown if all of its ancestors are selected.
These features allow us to organise our data in an hierarchical manner and select aspects of our data according to the hierarchy.
As well as selecting or toggling layers, we can use the animation controls in the 'Places' window to display layers in sequence. We can visually blend some layers, by selecting a layer in the 'Places' window and moving the slide bar that sets the transparency.
Google Earth
allows us to interactively select Placemarks or other features from the
KML
files available for display according to time through the TimeStamp or TimeSpan elements. These can be placed within features, such as Placemarks.
Google Earth
then allows us to select features according to particular periods or moments in time and to animate sequences.
Whilst the TimeStamp and TimeSpan elements are designed for encoding temporal information, they can be used to encode any ordered or periodic data if this
is transformed into a series of arbitrary dates. We can thus use
Google Earth
to interactively slice and select the data available as 'Places' as we engage in exploratory visual analysis.
So far, our
KML
files and examples have been static and self-contained.
We can however make reference to external
KML
files within our
KML
documents. These are referenced by URLs and so we can serve elements into our
KML
files from documents located anywhere on the Web.
The documents referenced by the URLs may be static or may change dynamically over time. In the latter case
KML
files that we link to via the Internet may be generated periodically by a server or 'on the fly' whenever a request is made
through a server-side scripting language such as
PHP
. This gives us even more scope for generating data, maps and interactions to suit as we explore spatial data through visualization.
We include external links to
KML
files on the Web through the NetworkLink element. Doing so will include
KML
from an external source as referenced by the Url element in the NetworkLink.
When
Google Earth
loads the
KML
file it will replace the NetworkLink element with whatever is in the document referenced by the Url.
We can control certain conditions under which
Google Earth
will check the server and re-load the URL specified in the NetworkLink by adding child elements within a Url.
It is useful to use server-side programming to extract information from a database according to a particular query at a particular
time. Importantly,
Google Earth
will add the bounding box of the currently selected view to the URL used by a NetworkLink when a request is made of a remote server. We can access this information through server side programming languages such
as
PHP
that connect to an online database and thus use the parts of the Url that describe the current bounding box as parameters in a database query.
These features of
Google Earth
and
KML
provide real scope for interactive visual exploration. We can :
NetworkLinkFolder / DocumentTimeStamp / TimeSpan
Here we will consider examples that show how the TimeStamp, NetworkLink and Document and Folder elements can be used in
KML
for visualization.
Example #1 contains a section of a
KML
file that defines a Placemark with a TimeStamp indicating that the Placemark exists on 28th October 2007.
<Placemark><name>current location</name><description>i am here!</description><TimeStamp><when>2008-10-20</when></TimeStamp><Point><coordinates>-83.0000,39.9700</coordinates></Point></Placemark>The T symbol is used as a separator between date and time, which is in hourly notation and requires seconds as shown in example #2. Times in UTC should end with a Z.
...<TimeStamp><when>2008-10-20T15:00:00</when></TimeStamp>...The section of a
KML
file shown in example #3 contains a Folder, that in turn contains two Document elements. Each has an associated name and could include descriptions and other elements. Additional structural elements could be added within these Documents to build up a hierarchy for selecting particular aspects of the data in an hierarchical manner for visualization.
...<Folder><name>example folder</name><Document><name>first document within a folder</name><!-- add elements here : e.g. NetworkLink --></Document><Document><name>second document within a folder</name><!-- add elements here : e.g. Placemarks --></Document></Folder>...In example #4 a NetworkLink is used to refer to a
KML
on a remote server. It will load the data from the file 'shadedRelief.kml' into the
KML
file in which the NetworkLink resides.
...<NetworkLink><Url><href>http://www.gicentre.org/tutorials/gisGE/shadedRelief.kml</href></Url></NetworkLink>...The
KML
file referenced by the href element of the Url in example #4 is shown below in example #5. It includes a 'GroundOverlay' - a
KML
element that allows imagery to be draped on the surface of the Earth. The image is specified in the Icon element, and its bounding coordinates in the LatLonBox. The image used here was generated from the USGS National Elevation Dataset (NED) at 1" resolution (USGS 2008) using the
LandSerf
GIS.
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Document><name>ground overlay example</name><GroundOverlay><name>shaded relief</name><description>image showing shaded relief NE of Sacramento.source : USGS National Elevation Dataset (NED) 1" resolution from seamless.usgs.govimage produced using LandSerf GIS.</description><LatLonBox><north>39.0419</north><south>38.632</south><east>-120.7295</east><west>-121.1819</west></LatLonBox><Icon><href>http://www.gicentre.org/tutorials/gisGE/shadedRelief.jpg</href></Icon></GroundOverlay></Document></kml>Example #6 uses the Url of a NetworkLink to request a document containing a server-side script, rather than a static
KML
file.
Note how the URL that is contained in the href element of the Url refers to a
PHP
script rather than a
KML
document. The
PHP
script will generate a
KML
document every time the URL is requested. In this case the script creates a single Placemark with a random location that changes on each request. The other elements within Url determine how and when the requests are made.
...<NetworkLink><name>randomPoint.kml</name><Url><href>http://www.gicentre.org/tutorials/kmlGE/randomPoint.php</href><refreshMode>onInterval</refreshMode><refreshInterval>4</refreshInterval><viewRefreshMode>onStop</viewRefreshMode><viewRefreshTime>1</viewRefreshTime></Url></NetworkLink>...
The refreshMode element is used to indicate that the NetworkLink should be updated at a particular interval. This is specified in the refreshInterval element.
The viewRefreshMode element is used to indicate that the NetworkLink should also be updated when the view is changed - when the user changes location in
Google Earth
. The time delay between a change of location or view and the data being refreshed is specified in the viewRefreshTime element.
Use the example code provided above to :
TimeStamp to one or more of your Placemarks
NetworkLink to the 'shadedRelief.kml' file at :
http://www.gicentre.org/tutorials/gisGE/shadedRelief.kmlNetworkLink to the 'randomPoint.kml' file at :
http://www.gicentre.org/tutorials/kmlGE/randomPoint.kmlNetworkLink is working, experiment with :
refreshIntervalviewRefreshTimePlacemarks and NetworkLinks into Documents and Folders.
This example uses the geographic information appended by
Google Earth
to the Url in a NetworkLink to search an online database.
A
PHP
script on the server processes this information about the bounding box of the current view and subsequently issues a database
query.
The query returns those geographic features within the specified view.
The script then formats the results using the
KML
elements that we have considered in this tutorial and returns this data to
Google Earth
.
This
KML
file contains three layers that retrieve data from the
Flickr
database representing the 1000 most interesting photographs in the current view. Placemarks are used to display the data in
Google Earth
and TimeStamps provide controls for visualization by encoding :
TimeStamp encodes date and time photograph taken. This layer is initially selected.
TimeStamp encodes time of day photograph taken. This layer must be selected from the 'Places' window.
TimeStamp encodes order of 'interestingness'. This layer must be selected from the 'Places' window.
Use these examples to further explore the
Flickr
database.
Change your viewing position, and zoom in to areas of interest to interactively filter the data geographically. You will see
more results and more detail as you use
Google Earth
to explore the geography of this database of point georeferenced photographs. Select each of the three layers in turn and
use the time line to consider the three alternative ordered sequences : date; time of day; interestingness.
'Interesting' Flickr photograph times and locations can be explored through the Google Earth timeline in exercise 5.