If you don't have a Start menu entry for Google Earth, you can add one by:
C:\Program Files (x86)\Google\Google Earth\client
googleearth.exeand select Pin to start menu
KML structures geodata
HTML and KML are both "flavors" of XML
<?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark> <name>Frew's office (Bren Hall 4524)</name> <description>http://frew.eri.ucsb.edu</description> <Point> <coordinates>-119.84183,34.413415,0</coordinates> </Point> </Placemark> </kml>
into Notepad++ and save as
frew.kml in Windows Explorer.
(Windows knows that files with names ending in
should be opened by Google Earth.)
Google Earth launches and you see something like this:
<?xml version="1.0" encoding="utf-8"?>
This document is marked up with XML, as defined by version 1.0 of the XML standard, and possibly including non-Roman-alphabet characters (e.g., всемирная паутина).
All XML documents require this as the first line of text.
The top-level XML element ("there can be only 1..."). Everything
kml element is marked up with KML, as
defined by version 2.2 of the KML standard.
Placemark element defines a single placemark,
one of the fundamental KML geographic feature types. Just a like a
feature in a shapefile, a placemark has both geometry and
<name>Frew's office (Bren Hall 4524)</name>
name is a required text attribute for a placemark.
Google Earth will display the value of
name next to
whatever icon it uses for the placemark; other KML clients may do
other things with it.
Note: By convention, KML uses capitalized tag names (e.g.
Placemark) for elements that can contain other elements. (Yes, the
kmlelement is an exception to this...)
description is an optional text attribute for a
placemark. Google Earth will display the value of
inside a pop-up text balloon when you select (click on) the
associated placemark. Google Earth recognizes URLs in a
and makes them live (clickable).
Point defines the placemark's geometry. KML supports
all the usual vector geometry types: points, lines, polygons, etc.
Point element must always contain a
element, which specifies the placemark's location in WGS 84
geographic (lat-lon) coordinates.
Note: WGS 84 is the only coordinate system supported by KML.
</Point> </Placemark> </kml>
Click on this link: Islay.kmz. Save it somewhere and then double-click on the saved file. This is a simple example of a KML document with multiple features and image annotations.
.kmz suffix indicates that the file is a compressed
KML document. If you want to see what's inside it (as
opposed to just displaying it), you have to uncompress it first.
From Windows Explorer, right-click
and select 7-Zip→Extract to "Islay\". This will create
the following folder structure:
Islay\ doc.kml images\ Ardbeg.jpg Bruichladdich.jpg ...
That's right, a
.kmz file is really a Zip archive
.kmz file always contains a top-level file named
doc.kml which is the actual KML document. The KMZ
format is thus often used to compress a really huge KML document
so it will download faster.
.kmz file may also contain any number of
additional files and folders, which
.kmz file can thus be a stand-alone
packaging containing all the data needed to render the map.
In this example, the folder
images contains image
files that are referenced by placemark
doc.kml. (Look at
in Notepad++ to see how this is done.)
Seriously, while KML is full-flegded vector data format (it can do everything a shapefile can, except for coordinate systems other than WGS84), it's really a map document format:
KML documents can include lots of styling information
KML allows for some degree of interactivity (if the client supports it)
We could teach a whole class on this (we teach some in the advanced GIS course). Meanwhile, if you want to go hog-wild with KML bells-n-whistles, check out:
To display a KML document in ArcGIS, use the KML To Layer tool.
To export an ArcGIS map layer, use the Layer to KML tool.
To export an entire ArcGIS map's active layers, use the Map To KML tool.
The ArcGIS KML export tools do correctly save the layer(s)'s style information in the generated KML.
You can load a local
file into Google Earth, QGIS, ArcGIS, etc.; but you can't load a
local file into a web browser that's running a mapping application
like Google Maps. This is for security reasons (otherwise, any Web
program could upload random files from your computer to evil.com or wherever.)
In order to load a KML document into a browser-based mapping client, the KML document must be accessible via a URL. In plain English, this means you have to park it on a web server somewhere.
Once upon a time (like, a couple of years ago) you could display KML in Google Maps just by dropping the URL into the Google Maps search box. That doesn't work anymore—the only way to do this is to create a web page that has some code in it that loads the KML into a Google Map. Here's are a couple of examples:
Note that Google Maps isn't as flexible as Google Earth (for example, note that the cute whisky glass icons aren't displayed.) However, Google Maps only needs a web browser, whereas Google Earth requires a whole separate client. Your choice...