Skip to main content

mlt_py

Python bindings for the MapLibre Tile (MLT) format via PyO3.

Decoding

import maplibre_tiles

data = open("tile.mlt", "rb").read()

# Structured decode with geo-referencing
layers = maplibre_tiles.decode_mlt(data, z=14, x=8297, y=10749, tms=True)
for layer in layers:
    print(f"Layer: {layer.name}, extent: {layer.extent}")
    for feat in layer.features[:3]:
        print(f"  id={feat.id}, type={feat.geometry_type}")
        print(f"  wkb={len(feat.wkb)} bytes, props={dict(feat.properties)}")

# Raw tile-local coordinates (no z/x/y needed)
layers = maplibre_tiles.decode_mlt(data)

# GeoJSON string output (tile-local coords)
geojson_str = maplibre_tiles.decode_mlt_to_geojson(data)

# Fast layer listing (no full decode)
names = maplibre_tiles.list_layers(data)

Decoded objects

decode_mlt(...) returns a list of MltLayer objects. Each MltLayer represents one decoded MLT layer and exposes:

  • name: str - the layer name.
  • extent: int - the layer extent.
  • z_step: int | None - the power of ten of the z grid's step in metres, or None when the vertices carry no z.
  • features: list[MltFeature] - the decoded features in that layer.

Each MltFeature represents one decoded feature and exposes:

  • id: int | None - the feature id, if present.
  • geometry_type: str - the decoded geometry type.
  • wkb: bytes - the geometry as WKB. A layer with z writes ISO WKB Z, with grid values in tile coordinates and elevations in metres once z/x/y project.
  • properties: dict - the feature properties.
import maplibre_tiles


layers = maplibre_tiles.decode_mlt(data)
for layer in layers:
    print(layer.name, layer.extent)
    for feature in layer.features[:2]:
        print(feature.id, feature.geometry_type, dict(feature.properties))

Encoding

encode_geojson(geojson, name, extent=4096, *, tessellate=False, sort="auto", shared_dict=True, fsst=True, fastpfor=True, z_step=None) -> bytes encodes a single layer to an MLT blob.

  • geojson is a GeoJSON FeatureCollection. Geometry is in tile-local coordinate space (no projection), matching tilezen/mapbox-vector-tile's default. Coordinates must be integers, and 2D unless z_step is set. They must be JSON integers (2048), not floats: a float-typed value such as 2048.0 raises ValueError.
  • name and extent set the MLT layer metadata, since a FeatureCollection has no slot for them. extent defaults to 4096.
  • tessellate generates triangulation data for polygons and multi-polygons.
  • sort controls which feature ordering(s) the encoder tries: all, auto, morton, hilbert, id, or none.
  • shared_dict enables grouping strings into shared dictionaries.
  • fsst enables FSST string compression.
  • fastpfor enables FastPFOR integer compression.
  • z_step is the power of ten of the z grid's step in metres, from -3 (1 mm) to 4 (10 km). Every position is then [x, y, z], where z = 0 sits at -10000 m, and the layer is written in the experimental v2 format.

encode_mvt(data, *, tessellate=False, sort="auto", shared_dict=True, fsst=True, fastpfor=True) -> bytes encodes an entire raw Mapbox Vector Tile (protobuf) to MLT using the same encoding options.

import maplibre_tiles


blob = maplibre_tiles.encode_geojson(
    {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "id": 1,
                "geometry": {"type": "Point", "coordinates": },
                "properties": {"name": "main", "lanes": 3},
            },
        ],
    },
    name="roads",
    extent=4096,
)


# Multi-layer tiles -> encode each layer and concatenate the bytes
tile = b"".join([
    maplibre_tiles.encode_geojson(roads, name="roads"),
    maplibre_tiles.encode_geojson(water, name="water"),
])
import maplibre_tiles


mvt = open("tile.mvt", "rb").read()

blob = maplibre_tiles.encode_mvt(mvt)


# With explicit encoding options
blob = maplibre_tiles.encode_mvt(
    mvt,
    tessellate=False,
    sort="auto",
    shared_dict=True,
    fsst=True,
    fastpfor=True,
)

Input is validated strictly. A non-FeatureCollection input, a non-Feature member, float-typed or 3D coordinates, null or empty geometry, nested or non-scalar property values, a non-u64 id, and an empty collection all raise ValueError.

Metadata

Release files for maplibre-tiles 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maplibre-tiles 0.2.8
File Size Uploaded
maplibre_tiles-0.2.8.tar.gz 472.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for maplibre-tiles 0.2.8
File
maplibre_tiles-0.2.8-cp314-cp314-manylinux_2_31_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.31+ x86-64 Details
maplibre_tiles-0.2.8-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.8-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.8-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.8-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.8-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.8-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.8-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.8-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.8-cp310-cp310-manylinux_2_31_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.31+ x86-64 Details

Total release size: 21.7 MB

Release files / maplibre_tiles-0.2.8.tar.gz

Download URL maplibre_tiles-0.2.8.tar.gz
Size 472.9 kB
Tags Source
SHA-256 checksum
How to use checksums
12cacd22b4046eb2f889c0a769a695f37361c2e7bc730a8738c714f37d6675d1
BLAKE2b-256 checksum
How to use checksums
9349fd2b13c7f5f344b24381a7961e9f185da7bbd31c7bfd0896ace752c8b492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp314-cp314-manylinux_2_31_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp314-cp314-manylinux_2_31_x86_64.whl
Size 1.1 MB
Tags CPython 3.14 Linux glibc 2.31+ x86-64
SHA-256 checksum
How to use checksums
ccdea24c8776ba71759b7142b860358a7a73021d76f5c3553c624ced24e59542
BLAKE2b-256 checksum
How to use checksums
e1acbf8952b86887cad592c809cf2ca68396cfc5badf5c1f5c83daba361a7f40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp314-cp314-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.8-cp314-cp314-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f97ddb2666abb1219b257ae61731e22be2a62908141de1e8e989044923a79016
BLAKE2b-256 checksum
How to use checksums
a85c345eeafb7d2445a72eb6085e605ba215f9ab7fa6250782918ec612f4644c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp314-cp314-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp314-cp314-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
642ec8b5c539e0521e6c4c818edb84d97e331e94efb8790faa8e0859c9e0882a
BLAKE2b-256 checksum
How to use checksums
ccc4da869eb2e3f687256e4a409b31fda69e7336c4e52392116c8a1cc988ea86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp313-cp313-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.8-cp313-cp313-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
411b04b45d0437d27a120bcca42c8280ed5451c4ef5eae3e2699dcab02185e11
BLAKE2b-256 checksum
How to use checksums
3b2eab088ce0a21edef49db90f04e4e333178f8fe17f858caf26691d3d000856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp313-cp313-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp313-cp313-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
743d897c6aa76ffcad942960813874d505864ac18bcb8062bf0438e0d58f0f7f
BLAKE2b-256 checksum
How to use checksums
02e960599ac7a41feb60d1a57d763bea8fc80a25038e2c45bcb533179bd400ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp312-cp312-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.8-cp312-cp312-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bce9df9dc0dc3429af62c9978e55a73dcf4442c2203a07769111af26ca683333
BLAKE2b-256 checksum
How to use checksums
ca8f0f18a37ce84977fa39409f8106306c0fed1a95e01cbe9e3d6aa3019c23d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp312-cp312-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp312-cp312-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
951e04fe8f37f4ddd082d80882995c5094f828114580604ffeeb1cd381903458
BLAKE2b-256 checksum
How to use checksums
c14242d8bc0edeec8af294c6da5dd948ccab9a6bf2cba7a0fb25eb7a9c2c4189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp311-cp311-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.8-cp311-cp311-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7f8b9cc879a0e7b542a88dd80912ba8c9b38b46e652f0f415b727f6dba7ab796
BLAKE2b-256 checksum
How to use checksums
7a13aacc6dd7adc321f446b0ee63f916110d504d48acaa6e6eaaabfacb9daa7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp311-cp311-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp311-cp311-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
54d18581abdbaee5312f31b1d92e3511b27c7a18ae51b2bc4a274a24e9364afc
BLAKE2b-256 checksum
How to use checksums
188783e547626f5d7f36487706368fdf876c18f3fa79bd3efebff9a560e6fa44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / maplibre_tiles-0.2.8-cp310-cp310-manylinux_2_31_x86_64.whl

Download URL maplibre_tiles-0.2.8-cp310-cp310-manylinux_2_31_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.31+ x86-64
SHA-256 checksum
How to use checksums
bfc43cd18f9fb81a72ba625078d29b5554109de45e373dded9ee6f98ced9a75d
BLAKE2b-256 checksum
How to use checksums
703624fabdf927cdc79eb87c596045100f36b620655083a4535018c89a83abc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.8 This release

11 release files

0.2.2

11 release files

0.2.1

11 release files

0.2.0

11 release files

0.1.9

11 release files

0.1.8

11 release files

0.1.7

11 release files

0.1.6

11 release files

0.1.3

11 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page