Skip to main content

kmlb logo

KMLB

Plain Python KML Builder.

Python PyPI License: MIT

KMLB is a dependency-free Python library for writing Google Earth KML files. Easily create points, lines, polygons, styles, and folders.

Full documentation at kmlb.dev.


Installation

pip install kmlb

Requires Python 3.9+. No third-party dependencies.


Quick example

import kmlb

# Define a reusable style and a styled point
style = kmlb.point_style("city", color=("#ff8800", 100), scale=1.4)
boston = kmlb.point([-71.0589, 42.3601], "Boston", style_to_use="city")

# Assemble a document and write it to disk
kmlb.kml("My Places", [boston], styles=[style], path="my_places.kml")

Open my_places.kml in Google Earth to view it.


Orange wireframe building footprints extruded into 3D over Google Earth satellite imagery

Building footprints extruded into 3D and viewed in Google Earth, built with kmlb polygons.

Modules

Module Description
kmlb Build points, POI/address searches, lines, polygons (with holes), point/line/polygon styles, folders, camera angles, and KML documents; geodesic distance, bearing, and destination
kmlb.shapes Composite geometry: wedge (a pie-wedge polygon)
kmlb.colors / kmlb.icons Named color presets and built-in marker shorthands for styling, so color="red" and icon="triangle" instead of hex tuples and full icon URLs

The core builders are re-exported at the top level, so kmlb.point(...), kmlb.kml(...), and friends work directly. See the reference for every function.


Example use

Writing a basic KML file

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
)

Mapping a POI or an address

import kmlb

# CREATE A POINT FROM A POI
bos_common = kmlb.search_poi("Boston Common, Boston, MA")

# CREATE A POINT FROM AN ADDRESS
ss = kmlb.search_poi("700 Atlantic Avenue, Boston, MA", name="South Station")

# WRITE KML FILE
kmlb.kml(
    "Boston Landmarks",          # KML name
    [bos_common, ss],            # Features
    path="folder/boston_landmarks.kml"  # Export path
)

Creating a customized KML file

import kmlb

# DEFINE A STYLE
pt_style = kmlb.point_style(
    "Red Triangle",                # Point style name
    icon="triangle",               # Icon (built-in shorthand)
    color=("#ff0000", 100),        # Icon color (hex, opacity)
    scale=1.0,                     # Icon scale
    label_color=("#ffffff", 100),  # Label color (hex, opacity)
    label_size=1.0,                # Label size
)

# CREATE A POINT
clock_tower = kmlb.point(
    [-71.053568, 42.359053, 151],                   # Coordinates
    "Custom House Tower",                           # Name
    headers=["City", "Building", "Height (M)"],     # Attribute titles
    attrs=["Boston", "Custom House Tower", "151"],  # Attributes
    z_mode="RTG",                                   # Relative To Ground
    style_to_use="Red Triangle",                    # Name of point style defined earlier
)

# WRITE KML FILE
kmlb.kml(
    "Boston Clock Tower",                     # KML name
    [clock_tower],                            # Features to include
    path="folder/boston_clock_tower.kml",     # Export path
    desc="Created with KMLB Python Package",  # KML description
    styles=[pt_style],                        # Styles to include
)

Functions

Function What it does
Features
point Point placemark from a [lon, lat] (or [lon, lat, elev]) coordinate.
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
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.
Geodesy (WGS-84)
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
shapes.wedge Pie-wedge (circular sector) polygon, useful for cellular coverage sectors.
Views, documents, and links
look_at Camera angle and view for a feature or document.
folder Group features and other folders together.
kml Assemble features and styles into a KML document and write it to disk.
networklink_kml Network-link KML that refreshes from a hosted URL.
Color and icon helpers
colors Named color palette (colors.RED, or color="red").
icons Built-in marker shorthands (icon="triangle", "red-paddle").

Citing KMLB

Using KMLB in research or published work? A citation is appreciated (it is not required under the MIT license, but documented use builds trust in the tool). APA, Chicago, and BibTeX formats, kept current with each release, are at kmlb.dev/docs/cite.

@software{KMLB,
  author  = {Mros, III, Henry F.},
  title   = {KMLB: KML Builder},
  year    = {2026},
  version = {0.1.0},
  url     = {https://pypi.org/project/kmlb/}
}

License

MIT. Free to use, modify, and redistribute, including in commercial or proprietary tools, as long as the copyright notice and license text are retained.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kmlb-0.2.0.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kmlb-0.2.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file kmlb-0.2.0.tar.gz.

File metadata

  • Download URL: kmlb-0.2.0.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.5"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.20 7 Apr 2026","python":"3.14.5","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

File hashes

Hashes for kmlb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 64cb532d8b810787820e39446a0060779812071f61a550f574dbc10b1455847f
MD5 7229815c81ca630640d0744784c0a560
BLAKE2b-256 81af4127733263e05b9d95b6e725e46a0c2fa60b4d90723ba6f82f1412bc9039

See more details on using hashes here.

File details

Details for the file kmlb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kmlb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.5"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.20 7 Apr 2026","python":"3.14.5","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

File hashes

Hashes for kmlb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f02ff605034d8ab11a9e6f48cd192ee5b43870b0ae82a45cfa6043f336ac8811
MD5 602b566b96ae3246a299984de79e86cd
BLAKE2b-256 7b41a0ce92c3372859fc759f832ec459727c910416dbb6c08f0ef2e441f16749

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0.post1

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.94

2 files

0.0.93

2 files

0.0.92

2 files

0.0.91

2 files

0.0.90

2 files

0.0.88

2 files

0.0.87

2 files

0.0.86

2 files

0.0.85

2 files

0.0.84

2 files

0.0.83

2 files

0.0.82

2 files

0.0.81

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page