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.6

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.6
File Size Uploaded
maplibre_tiles-0.2.6.tar.gz 466.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for maplibre-tiles 0.2.6
File
maplibre_tiles-0.2.6-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.6-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.6-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.6-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.6-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.6-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.6-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.6-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
maplibre_tiles-0.2.6-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details
maplibre_tiles-0.2.6-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.5 MB

Release files / maplibre_tiles-0.2.6.tar.gz

Download URL maplibre_tiles-0.2.6.tar.gz
Size 466.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3728bd02d3716daf3adedd10a21e32554d306f469570c95d9eab171d3fd73688
BLAKE2b-256 checksum
How to use checksums
23ed0e91dc32ade07062f3d8c5bc2e9341d8c76d83419e1db083276f20843254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp314-cp314-manylinux_2_31_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
a1ae56dd48c069812986beb07f0714f4e1693b80b4c3f50a344785434dfc74a5
BLAKE2b-256 checksum
How to use checksums
a85925fb4b6f44e1847b016b0858bb054308774755702882210801f568a5ce99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp314-cp314-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.6-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
b1009108690f41ee0b4719815540e422de4c9505eb943e74ac8432e1efaf1e39
BLAKE2b-256 checksum
How to use checksums
47e00cd27095b3cbc0a218f3a23559dc7992a8bba4d8c74ec97659b2cbf6f543
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp314-cp314-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
8624db3c475e2a506835686858cc7be00995ecc67ad14aab7b5be828d7aec8dc
BLAKE2b-256 checksum
How to use checksums
6619b984a9c16865137169b4ebb1fa853873c17a34f426e3c06e5e72d9c6a034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp313-cp313-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.6-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
1aad92dcff9a51ba9d58dc3e042dd55f8e186f7ec0c1aa797bf01b71d35c3f49
BLAKE2b-256 checksum
How to use checksums
09557522147b1cb916d69e0d5bbd9a2167fb27d9b719ccf93dd8824977592397
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp313-cp313-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
1cb363809cfd206ec3bd509f3a11678fcce4e092b08c928103f8219589f120b9
BLAKE2b-256 checksum
How to use checksums
919a9d8c0ac04a7028d395d709a338295ed6f9a4288cfa5761f97b9d76439092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp312-cp312-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.6-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
58bed7810e72ca2b4b3d817569feafdd20ab007a93af91fcd1462bf9edfa5f45
BLAKE2b-256 checksum
How to use checksums
2365e2fda591be80f08eef759afea5263a0c33c1a8cdba36c465eb77b9711581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp312-cp312-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
1061dda626cf1372fd91300cbbf381de0d45c31f5850df605ab51b3a721f38aa
BLAKE2b-256 checksum
How to use checksums
ac6a9f814fbef6ffd6508ba9302d969a9a74006524795975b9fcffaed38f4980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp311-cp311-macosx_11_0_arm64.whl

Download URL maplibre_tiles-0.2.6-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
717a7d930980d6e74c61c3d2588f48ca40efa00572c5cbfb88e8a70634e8ed3b
BLAKE2b-256 checksum
How to use checksums
65e103332046cbc20c8217ac6889805839a11068a5fd3cf758aee543b0f6396a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp311-cp311-macosx_10_12_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
4a9e8704ec43f13149711003b5394eeb3eebd542539df0d1fe735f55f3da76c7
BLAKE2b-256 checksum
How to use checksums
4a3eda2adb8a3610921910e3a7ef3473bd6ef2b6ea3464d1d97ee72fef6957b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6-cp310-cp310-manylinux_2_31_x86_64.whl

Download URL maplibre_tiles-0.2.6-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
c1778a11659addcb2fd72d9512a8d35a9629eb39b1dcd0066571f344f26d3c57
BLAKE2b-256 checksum
How to use checksums
0088a2feef84343dd3f07fb0d575b63ecad92bb9f5c88b3dde30c3890bee7a2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","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.6 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