Examples for working with raw kml/kmz files exported from the app.

This page provides examples of kmz/kml file post processing that you might find useful.

Preparation:

  1. Export from GPS Camera: Export points as KMZ/KML
  2. Extract KML: Unzip KMZ if needed

Updating KML Placemark Names from imageNotes

This guide demonstrates how to automatically update placemark names in your KML files by extracting information from the imageNotes field.

Overview

When exporting points from GPS Camera, the app creates KML files with placemark names based on photo and point titles. The note content (like “Note 1”, “Note 2”, etc.) is stored in the imageNotes field as tab-separated values. This script allows you to automatically extract that note information and use it as the placemark name, if needed.

It’s probably the best to just put your notes into the Title field as you take photos. This script would serve if you were not doing so and also just as an example for the kml post processing.

Use Case

Before:

  • Placemark names show timestamps: 15Nov25 16:25, 12Nov25 17:24
  • Actual notes are hidden in the imageNotes field: Note 1, Note 2

After:

  • Placemark names show meaningful notes: Note 1, Note 2
  • Easy to identify points at a glance in mapping applications

KML File Structure

The exported KML file contains placemarks with the following structure:

<Placemark>
  <name>15Nov25 16:25</name>
  <ExtendedData>
    <SchemaData schemaUrl="#blcPointSchema">
      <SimpleData name="imageNotes"><![CDATA[15Nov25 16:25	Note 1		Ad-hoc	V Třešňovce 227/12...]]></SimpleData>
    </SchemaData>
  </ExtendedData>
  <Point>
    <coordinates>14.502834,50.095184,239.0</coordinates>
  </Point>
</Placemark>

The imageNotes field contains tab-separated values:

  • Field 0: Timestamp (15Nov25 16:25)
  • Field 1: Note text (Note 1) ← This is what we extract
  • Field 2: Empty
  • Field 3: Type (Ad-hoc)
  • Field 4: Address

Solution: Python Script

We’ve created a Python script that automatically processes KML files and updates placemark names based on the imageNotes content.

Script Features

  • Automatic extraction: Parses tab-separated imageNotes field
  • Position-based: Extracts note from a specific field position (default: position 1)
  • Generic: Works with any KML file following this structure
  • Safe: Creates backups before overwriting files
  • Flexible: Can output to a new file or update in place

How It Works

  1. Parse KML file: Reads the XML structure
  2. Find placemarks: Locates all <Placemark> elements
  3. Extract notes: Splits imageNotes by tab character and gets the note at position 1
  4. Update names: Replaces the entire <name> element with the extracted note
  5. Save output: Writes updated KML to file

Installation & Usage

Prerequisites

  • Python 3 (pre-installed on macOS, download from python.org for Windows)
  • No additional libraries required (uses standard library only)

Step-by-Step Guide

1. Download the Script

Download update_kml_names.py and place it in the same folder as your KML file.

2. Run the Script

macOS / Linux:

# Navigate to the folder containing your KML file
cd ~/Downloads/Points_20251115_163211

# Run the script (creates backup, updates original)
python3 update_kml_names.py doc.kml

# Or create a new output file (keeps original)
python3 update_kml_names.py doc.kml updated_points.kml

Windows:

# Navigate to the folder containing your KML file
cd %USERPROFILE%\Downloads\Points_20251115_163211

# Run the script (creates backup, updates original)
python update_kml_names.py doc.kml

# Or create a new output file (keeps original)
python update_kml_names.py doc.kml updated_points.kml

3. View Results

The script will display the updates:

Updated: '15Nov25 16:25' -> 'Note 1'
Updated: '12Nov25 17:24' -> 'Note 2'

Completed! Updated 2 placemark(s).
Output saved to: doc.kml

Advanced Usage

Custom Note Position

If your imageNotes field has a different structure and the note is in a different position, you can specify it:

# Extract note from position 2 (third field, 0-indexed)
python3 update_kml_names.py doc.kml output.kml 2

Batch Processing

You can process multiple KML files using a simple script:

macOS / Linux:

for file in *.kml; do
  python3 update_kml_names.py "$file"
done

Windows (PowerShell):

Get-ChildItem -Filter *.kml | ForEach-Object {
  python update_kml_names.py $_.Name
}

Example: Before and After

Before Processing

<Placemark>
  <name>15Nov25 16:25</name>
  <SimpleData name="imageNotes">15Nov25 16:25	Note 1		Ad-hoc	Address...</SimpleData>
</Placemark>

<Placemark>
  <name>12Nov25 17:24</name>
  <SimpleData name="imageNotes">12Nov25 17:24	Note 2		Ad-hoc	Address...</SimpleData>
</Placemark>

After Processing

<Placemark>
  <name>Note 1</name>
  <SimpleData name="imageNotes">15Nov25 16:25	Note 1		Ad-hoc	Address...</SimpleData>
</Placemark>

<Placemark>
  <name>Note 2</name>
  <SimpleData name="imageNotes">12Nov25 17:24	Note 2		Ad-hoc	Address...</SimpleData>
</Placemark>

Technical Details

Script Implementation

The script uses Python’s built-in XML parser (xml.etree.ElementTree) to:

  • Parse KML files with proper namespace handling
  • Navigate the XML structure to find placemark elements
  • Extract and process tab-separated values
  • Update elements while preserving file structure

Compatibility

  • KML version: 2.2 (standard format)
  • Python version: 3.6+
  • Operating Systems: macOS, Windows, Linux
  • Apps: Compatible with Google Earth, QGIS, ArcGIS, and other KML-supporting applications

Troubleshooting

Issue: Script not found

Cause: Python not installed or not in system PATH

Solution:

  • macOS: Python 3 should be pre-installed
  • Windows: Download from python.org and ensure “Add to PATH” is checked during installation

Issue: Empty names after update

Cause: Note field is empty or in wrong position

Solution: The script will show a warning. Check your imageNotes format and adjust the position parameter.

Integration with Your Workflow

This script can be integrated into automated workflows:

  1. Export from GPS Camera: Export points as KMZ/KML
  2. Extract KML: Unzip KMZ if needed
  3. Run script: Process KML to update names
  4. Import to GIS: Use in Google Earth, QGIS, or other tools

Source code

#!/usr/bin/env python3
"""
Script to update KML placemark names with Note from imageNotes field.
Extracts the note from the tab-separated imageNotes field (position 2) and replaces the placemark name.
"""

import xml.etree.ElementTree as ET
import sys
import os

def update_kml_with_notes(input_file, output_file=None, note_position=1):
    """
    Update KML placemark names by extracting Note from tab-separated imageNotes field.

    Args:
        input_file: Path to input KML file
        output_file: Path to output KML file (if None, overwrites input)
        note_position: Position of the note in tab-separated imageNotes (0-indexed, default 1)
    """
    # Parse the KML file
    tree = ET.parse(input_file)
    root = tree.getroot()

    # Define namespace
    ns = {'kml': 'http://www.opengis.net/kml/2.2'}

    # Find all Placemark elements
    placemarks = root.findall('.//kml:Placemark', ns)

    updated_count = 0

    for placemark in placemarks:
        # Get the current name
        name_elem = placemark.find('kml:name', ns)
        if name_elem is None:
            continue

        current_name = name_elem.text

        # Find the imageNotes field
        image_notes_elem = placemark.find('.//kml:SimpleData[@name="imageNotes"]', ns)

        if image_notes_elem is not None and image_notes_elem.text:
            image_notes = image_notes_elem.text

            # Split by tab to get the note (tab-separated format)
            parts = image_notes.split('\t')

            if len(parts) > note_position and parts[note_position].strip():
                note_text = parts[note_position].strip()

                # Update the name - replace entirely with the note
                name_elem.text = note_text

                print(f"Updated: '{current_name}' -> '{note_text}'")
                updated_count += 1
            else:
                print(f"Warning: No note found at position {note_position} in imageNotes for placemark '{current_name}'")
                print(f"  imageNotes content: {image_notes}")
        else:
            print(f"Warning: No imageNotes found for placemark '{current_name}'")

    # Determine output file
    if output_file is None:
        output_file = input_file

    # Write the updated KML
    tree.write(output_file, encoding='utf-8', xml_declaration=True)

    print(f"\nCompleted! Updated {updated_count} placemark(s).")
    print(f"Output saved to: {output_file}")

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python3 update_kml_names.py <input_kml_file> [output_kml_file] [note_position]")
        print("\nArguments:")
        print("  input_kml_file:  Path to the KML file to process")
        print("  output_kml_file: (Optional) Output file path. If not provided, input will be overwritten.")
        print("  note_position:   (Optional) 0-indexed position of note in tab-separated imageNotes (default: 1)")
        print("\nExample:")
        print("  python3 update_kml_names.py doc.kml")
        print("  python3 update_kml_names.py doc.kml doc_updated.kml")
        print("  python3 update_kml_names.py doc.kml doc_updated.kml 1")
        sys.exit(1)

    input_file = sys.argv[1]
    output_file = sys.argv[2] if len(sys.argv) > 2 else None
    note_position = int(sys.argv[3]) if len(sys.argv) > 3 else 1

    if not os.path.exists(input_file):
        print(f"Error: Input file '{input_file}' not found.")
        sys.exit(1)

    # Create backup if overwriting
    if output_file is None:
        backup_file = input_file + '.backup'
        import shutil
        shutil.copy2(input_file, backup_file)
        print(f"Backup created: {backup_file}\n")

    update_kml_with_notes(input_file, output_file, note_position)

Support

For questions or issues:

  • Verify Python 3 is installed correctly
  • Check that imageNotes contains tab-separated values

License

This script is provided as-is for use with the app exports. Feel free to modify and adapt it to your specific needs.


Export & Import

Working with Google Earth


Last updated: November 2025