API Reference
Complete reference documentation for KML ORM’s classes, methods, and utilities.
Core Components
Overview
KML ORM provides a Django-style ORM for working with KML (Keyhole Markup Language) files. The API is designed to be familiar to Django developers while providing specialized functionality for geospatial data manipulation.
Key Features:
Familiar API: Django-style
.objects.all(),.filter(),.get()methodsType Safety: Full type annotation support throughout the API
Geospatial Queries: Built-in spatial operations like
.near()and.within_bounds()Spatial Calculations: Distance, bearing, and midpoint calculations with multiple strategies
Flexible Loading: Load KML from files, URLs, or strings
Robust Validation: Automatic coordinate and data validation
Getting Started
For a quick introduction, see the Quick Start Guide guide. For comprehensive examples, explore the Tutorial.
Example Usage
from kmlorm import KMLFile
# Load KML file
kml = KMLFile.from_file('places.kml')
# Query elements (include nested elements)
all_places = kml.placemarks.all()
nearby = kml.placemarks.all().near(-76.6, 39.3, radius_km=25)
# Chain complex queries
results = (kml.placemarks.all()
.filter(name__icontains='store')
.has_coordinates()
.order_by('name')
)