home / skills / dkyazzentwatwa / chatgpt-skills / kml-geojson-converter

kml-geojson-converter skill

/kml-geojson-converter

This skill converts geographic data between KML and GeoJSON, preserving features and enabling batch processing for mapping and GIS workflows.

npx playbooks add skill dkyazzentwatwa/chatgpt-skills --skill kml-geojson-converter

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.3 KB
---
name: kml-geojson-converter
description: Use when asked to convert between KML and GeoJSON formats, or convert geo data for mapping applications.
---

# KML/GeoJSON Converter

Convert geographic data between KML, GeoJSON, and other geo formats for mapping and GIS applications.

## Purpose

Geo format conversion for:
- Google Maps / Earth integration
- Web mapping applications (Leaflet, Mapbox)
- GIS data interchange
- Spatial data processing
- GPS track conversion

## Features

- **Bidirectional Conversion**: KML ↔ GeoJSON
- **Feature Preservation**: Maintain properties, styles, descriptions
- **Batch Processing**: Convert multiple files
- **Coordinate Systems**: WGS84, UTM support
- **Validation**: Verify output format validity
- **Simplification**: Reduce polygon complexity

## Quick Start

```python
from kml_geojson_converter import GeoConverter

# KML to GeoJSON
converter = GeoConverter()
converter.load_kml('input.kml')
converter.save_geojson('output.geojson')

# GeoJSON to KML
converter.load_geojson('input.geojson')
converter.save_kml('output.kml')
```

## CLI Usage

```bash
# Convert KML to GeoJSON
python kml_geojson_converter.py input.kml --to geojson --output output.geojson

# Convert GeoJSON to KML
python kml_geojson_converter.py input.geojson --to kml --output output.kml
```

Overview

This skill converts geographic data between KML and GeoJSON formats for mapping and GIS workflows. It preserves feature properties and styles, supports batch processing, and can validate and simplify geometry for efficient display. Use it to prepare data for Google Maps, Mapbox, Leaflet, or GIS analysis pipelines.

How this skill works

The converter loads KML or GeoJSON, parses features and their attributes, and maps geometry and property structures between formats. It preserves descriptions, styles, and metadata where possible, offers coordinate system handling (WGS84 and UTM), and can simplify polygons to reduce complexity. Validation checks confirm the output meets the target format schema before saving.

When to use it

  • Preparing KML for web maps that require GeoJSON (Leaflet, Mapbox, OpenLayers).
  • Exporting GeoJSON to KML for Google Earth or KML-based workflows.
  • Batch converting multiple files or folders for bulk ingestion.
  • Cleaning and simplifying GPS tracks or large polygon datasets for visualization.
  • Converting coordinate systems between WGS84 and UTM before analysis.

Best practices

  • Validate input files before conversion to catch malformed geometry early.
  • Preserve original attributes by inspecting property mappings and adjusting keys if needed.
  • Use geometry simplification for large datasets to improve performance on web maps.
  • Run conversions in batch mode for repeatable workflows and automation.
  • Test the converted output in the target application (Mapbox, Google Earth) to confirm styling and metadata transfer.

Example use cases

  • Convert a city zoning KML to GeoJSON for display in a Leaflet-based web map.
  • Batch-convert a folder of hiking GPX/KML tracks to GeoJSON for a mobile app.
  • Export GeoJSON building footprints to KML for inspection in Google Earth.
  • Simplify large coastal polygons before loading into a web map to improve tile performance.
  • Convert survey data from UTM coordinates to WGS84 GeoJSON for sharing with stakeholders.

FAQ

Will styles and descriptions always transfer between formats?

The converter preserves styles and descriptions where both formats support them, but some complex KML styling may not map exactly to GeoJSON styling conventions.

Can I automate bulk conversions?

Yes. The CLI and library both support batch processing so you can script conversions across many files.