Docs home
KMLB Docs
KMLB is a dependency-free Python KML builder for Google Earth. Write points, lines, polygons, styles, and folders in plain Python, then assemble them into a complete .kml
New to KMLB? Check out our Quick Start Guide and a tutorial that builds a KML of Boston waterfront attractions step by step.
Example KML Script
Every feature is one Python call that hands back an XML element. Define a feature, style it, then bundle it all into a document. That's the whole library.
import kmlb
# CREATE A POINT
fountain = kmlb.point([-71.051904, 42.358988, 0], "Rings Fountain")
# WRITE KML FILE
kmlb.kml(
"Boston Fountain", # KML name
[fountain], # Features
path="folder/boston_fountain.kml" # Export path
)
Building footprints extruded into 3D and viewed in Google Earth, built with kmlb polygons.
Function references
Every function in kmlb, grouped by what it does. Open any group for full signatures, parameters, and worked examples.
Features
Build placemarks from coordinates or a search, ready to drop into a folder or document.
| Function | Description |
|---|---|
point |
Point placemark from a [lon, lat] (or [lon, lat, elev]) coordinate sets. |
search_poi |
Placemark located by an address or search string, geocoded by Google Earth. |
line |
Line or polyline from an ordered list of coordinates. |
polygon |
Polygon from one or more rings (first ring outer, the rest holes). |
Styles
Define a reusable style once, name it, and reference it from a feature's style_to_use.
| Function | Description |
|---|---|
point_style |
Reusable point style: icon, color, scale, and label. |
line_style |
Reusable line style: color and width. |
polygon_style |
Reusable polygon style: fill and outline. |
Views & Export
Group features, set the camera, and write the document.
| Function | Description |
|---|---|
folder |
Group features and other folders together. |
kml |
Assemble features and styles into a KML document and write it to disk. |
look_at |
Camera angle and view for a feature or document. |
networklink_kml |
Network-link KML that refreshes from a hosted URL. |
Geodesy
Measure and project on the WGS-84 ellipsoid.
| Function | Description |
|---|---|
distance |
Distance in meters between two coordinates. |
bearing |
Initial bearing in degrees between two coordinates. |
destination |
Coordinate reached from an origin along a bearing and distance. |
Shapes
Higher-level geometry built on the core builders.
| Function | Description |
|---|---|
wedge |
Pie-wedge (circular sector) polygon, a natural fit for cellular coverage. |
Colors & Icons
Name colors and markers instead of hunting down hex tuples and icon URLs.
| Function | Description |
|---|---|
colors |
Named color palette (colors.RED, or color="red"). |
icons |
Built-in marker shorthands (icon="triangle", "red-paddle"). |
