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: 2D shapes (circle, ellipse, rectangle, ngon, annulus, arc, wedge, ribbon, con_rings, fishnet, hex_grid, hex_field), 3D solids (cylinder, cone, dome, sphere, cube, pyramid, soccer_ball), and fresnel_zone (RF link)
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.

Colored 3D cylinder, cone, dome, and sphere volumes placed over Boston in Google Earth

3D solids (cylinder, cone, dome, sphere) placed over Boston, built with kmlb.shapes.


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.
street_view Point placemark built from a Google Maps Street View URL that opens that panorama.
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.circle Circle polygon of a given radius around a point.
shapes.ellipse Ellipse polygon from two semi-axes and an orientation.
shapes.rectangle Rectangle polygon anchored at an upper-left corner, rotatable by azimuth.
shapes.ngon Regular polygon (triangle, pentagon, hexagon, ...) around a point.
shapes.annulus Filled ring polygon (an outer circle with a hole).
shapes.arc Range-of-reach arc drawn as a line.
shapes.wedge Pie-wedge (circular sector) polygon, useful for cellular coverage sectors.
shapes.ribbon Buffered polygon around a path; even or per-point width.
shapes.con_rings Folder of range-ring outlines from a list or a start/interval/count series.
shapes.fishnet Folder of rectangular grid cells from a corner; clickable, ID-able.
shapes.hex_grid Folder of tessellated hexagonal grid cells from a corner.
shapes.hex_field Folder of hexagonal cells in a hexagon-shaped cluster of rings around a center; cells numbered outward from the center.
shapes.fresnel_zone 3D Fresnel-zone tube plus line-of-sight path for a point-to-point radio link.
shapes.cylinder 3D cylinder volume (or a frustum via top_radius); orientable along any axis.
shapes.cone 3D cone; apex or base anchored, orientable along any axis.
shapes.dome 3D hemisphere dome (or bowl when inverted).
shapes.sphere 3D sphere; anchor by center or a pole.
shapes.cube 3D cube or rectangular box.
shapes.pyramid 3D pyramid with an n-sided base.
shapes.soccer_ball 3D truncated icosahedron, two-tone.
Views, documents, and links
look_at Camera angle and view for a feature or document.
camera Camera viewpoint (eye position and aim) 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").

A point-to-point Fresnel-zone tube and antenna coverage wedges drawn in 3D over Google Earth

A Fresnel-zone link tube and antenna coverage wedges, built with kmlb.shapes.


Citing KMLB

Using KMLB in research or published work? Citing is never required, but it's always appreciated. Even a quick mention helps others discover KMLB and shows where it's making a difference. 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.4.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.4.0.tar.gz (68.8 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.4.0-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmlb-0.4.0.tar.gz
  • Upload date:
  • Size: 68.8 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.4.0.tar.gz
Algorithm Hash digest
SHA256 b99afaa0a3e177ead6db2c9a32f06f5084dde36417cafd094ede87f3169642e5
MD5 33515aa1072366ed6e5c306641ea242e
BLAKE2b-256 5dc80b4933e16c1433ce814eade606a5d1e5977f8687fee75a19886eaaf23864

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmlb-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 47.7 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3482fd06fdb7fb48b3283a54b7477139dd7b1de270b5a7322e1f810fdd9cf2c
MD5 7babf5ae21c8007ced69195619941603
BLAKE2b-256 3bff9250ff37d1a5b9ad933013bd62784167705e3fb94fdfcc77e02f5defabc8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0.post1

2 files

0.3.0

2 files

0.2.0

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