Created the following utility which can be used to convert a CSV (Comma Separated Value) file into a KML file for use with Google Earth. See here for the rest of my development blog regarding other topics.

Description

The above google earth image was produced from this kml file which was produced by passing this sample input csv file into this perl script using the following command.

perl csv2kml.pl test1.csv test1.kml

Usage: perl csv2kml.pl <filename_in> <filename_out>
Column order is expected to be: name,description,timestamp,color,scale_or_line_width,point coordinates,line coordinates,polygon coordinates Only supply point OR line OR polygon coordinates for each row
Coordinates are space separated triples of: x y z

The input csv file can be used to create points, lines and polygons of various colors and scale with timestamps(see the input csv file for further notes on this). Color and scale can be used as part of a visual legend to indicate georeferenced data qualities or quantities. With Google Earth version 4 and greater, timestamp information can be used to provide time animations of data using the time controls.

The perl script requires the initialization file csv2kml.ini available in the same directory as the csv2kml.pl file to configure default parameters. The default parameters can be changed by the user as needed. Below is a listing of the parameters.

Windows version (.exe)

The perl script has also been converted to a Windows executable using perl2exe (see other notes on perl2exe here) so this can be run as a simple .exe without having perl installed. The command is called the same except using the .exe version

from a windows command prompt (Start->Run->type 'cmd')

csv2kml.exe test1.csv test1.kml

Google Maps

KML files can be referenced from Google maps (see examples here), but some KML functionality may be missing - usually works ok for a small number of points, but not as well for a large number of points, lines or polygons. To reference a kml file from google maps, pass the http reference to the kml file as the 'q=' argument like below which will produce the below map.

KMZ files

You can compress/zip a kml file using winzip or some other zipping tool and rename the zipped file with a .kmz extension. Google earth is able to open .kmz files directly and .kmz compression is preferred for large kml files.