blankblank blank




Using The KML Time Embedder To Stamp Time Data Into A Google Earth File



Since Google Earth currently doesn’t let you add time data to a KML file, you have to use an alternate approach like manually editing the KML file, or using one of several different spreadsheet-oriented methods. I’ve put together a third option, a “simple” Windows utility called “KML Time Embedder” that will let you specify the time information in a GUI, and embed it automatically into a KML file. There are a few limitations on its use:

1. KML files only, not KMZ (but if you have a KMZ file, you can open it in Google Earth and then save it as a KML file)

2. Only simple unstyled feature tags will work, e.g. <Document> will work while the valid <Document id=”Yourstyle”> won’t; if this turns out to be a problem for a lot of people, I might fix it. But then again, if you’re adding style IDs to KML, you’re probably wouldn’t use this utility anyway.

3. Only the first feature tag will have time data embedded after it; if this is a problem, you can always save individual KML files for every separate feature using Google Earth. Feature tags are:

  • <Folder>
  • <Document>
  • <Placemark>
  • <GroundOverlay>
  • <ScreenOverlay>
  • <PhotoOverlay>
  • <NetworkLink>

4. If a document already has time data embedded in it, it will be rejected.

5. There is some error-checking, but I suspect it’s not complete, so I’ve added a “verify” function that lets you manually inspect the time information before embedding it into the file.

6. This version only embeds date time, not hour/minute/second time; if enough people ask, I might add that capability. Done! Visit this post for the details.

I’ve posted two zip files with the program. The first one is just the executable (21 kB zipped) and requires some VB6 files that are probably already installed on your computer (especially if you’re running Windows XP SP2). If it doesn’t work, or if you want the full bells-and-whistles installation with a Start Menu item, try the full install package (2 MB zipped).

When the program runs, you’ll get the following extra-fancy interface:

fullscreen

The functions are:

Open Input KML File: Selects the KML file you want to embed time data into. If it finds time data already present, it will reject the file (see #4 above). If it can’t find an acceptable “feature” tag, it gets rejected as well (see #2 above).

Enter Output KML File: Select the name of the output file. It will check to make sure you’re not specifying the input filename as the output file, and also prompt you if you select an existing filename to make sure you want to overwrite it.

Auto Output File: After you’ve enter the time data, pressing this button will create an output filename by appending the time data to the end of the input filename.

KML Time Info Mode: Specifies the type of time data to be embedded.

TimeSpan is for data that is associated with a starting and ending time. If the time runs from a start time to the present, just leave the end TimeSpan blank.

TimeStamp is for data associated with a single specific time; selecting this disables the “end TimeSpan” input.

Enter beginning/end of TimeSpan, or TimeStamp data: After you select the input file, you can enter the beginning time and/or end time if appropriate, or just a TimeStamp (in TimeStamp mode, only one set of input boxes will be visible). Type the year directly into the box, and use negative numbers for BC. The program will check for valid numbers, and will reject the year 0 as invalid (because it *is* invalid; there is no year zero in the Western BC/AD year system). If you want the TimeSpan to run from a time in the past to the indefinite present, or are doing a TimeStamp, just leave the end TimeSpan section blank. Conversely, if you want the TimeSpan to run from the indefinite past and end at a specific date, leave the beginning TimeSpan section blank.

Verify Dates: Once you’ve entered your beginning date (and end date if desired), clicking on Verify Dates will display the time data at the bottom, and do a basic check to make sure that the beginning date is before the end date. If you specify month or day for one time, but not the other, that will be brought to your attention; while it’s probably best to make sure that both dates have the same sets of data entered (year-month-day), it doesn’t appear to be mandatory in KML. There are probably bugs in my validation routines, so you should make sure the dates are correct; if you find a case where the program says the dates are valid, and they’re not, please let me know.

Concluded tomorrow ….

Other free utilities can be found on the Utilities page. If you find this or any of my other utilities particularly useful and would like to show your appreciation, donations of any amount are gratefully accepted via PayPal.


Looking for something else? Enter some keywords below, then click "Search".