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, orNonewhen 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 oncez/x/yproject.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.
geojsonis a GeoJSONFeatureCollection. Geometry is in tile-local coordinate space (no projection), matchingtilezen/mapbox-vector-tile's default. Coordinates must be integers, and 2D unlessz_stepis set. They must be JSON integers (2048), not floats: a float-typed value such as2048.0raisesValueError.nameandextentset the MLT layer metadata, since aFeatureCollectionhas no slot for them.extentdefaults to4096.tessellategenerates triangulation data for polygons and multi-polygons.sortcontrols which feature ordering(s) the encoder tries:all,auto,morton,hilbert,id, ornone.shared_dictenables grouping strings into shared dictionaries.fsstenables FSST string compression.fastpforenables FastPFOR integer compression.z_stepis the power of ten of the z grid's step in metres, from-3(1 mm) to4(10 km). Every position is then[x, y, z], wherez = 0sits 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.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| maplibre_tiles-0.2.7.tar.gz | 467.0 kB | Details |
Built distributions (wheels)
Total release size: 21.5 MB
Release files / maplibre_tiles-0.2.7.tar.gz
| Download URL | maplibre_tiles-0.2.7.tar.gz |
|---|---|
| Size | 467.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b11de31067f2f7707652f13631d44139a9629e1455d2bd891677b218e7e3225
|
|
BLAKE2b-256 checksum How to use checksums |
70e2071563782ec51e3ba87d32bf7cbed31b6e4b594466844fa7fcefdc0608a9
|
| 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.7-cp314-cp314-manylinux_2_31_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
6ac904c513f01bae5c16678a9e20a119c5c46710fbb95f1f0a1908466c3a4f05
|
|
BLAKE2b-256 checksum How to use checksums |
0d84712f835f5fdbc9663fc2154bc3ba161b58ed69b87256ab67cbd2c7e06320
|
| 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.7-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
9c9ea223f4a24e116b063580413e32b69224d9d335a0bd0f2698fb975d2aee86
|
|
BLAKE2b-256 checksum How to use checksums |
c6ae18165b14fdeed06c2b63efbc33dd08f1535a751435628bbb585a9e5db649
|
| 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.7-cp314-cp314-macosx_10_12_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
9d625388d6a8ab6f14ade0e9e28a5fea3ba9d423acca33e5cd93802b70acf8ab
|
|
BLAKE2b-256 checksum How to use checksums |
e6d7eaea18b692012d36964ba835ee0436e1e60ff196806a0832819fa8dabb1e
|
| 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.7-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
4d5879f24f896a88dfdabeede5fb6c94aafe268c83789933e3bfbaeb8a90760b
|
|
BLAKE2b-256 checksum How to use checksums |
a6c8ef00e3af1517207e7ed4ac5c04dcb8aab329cec84ab3f99f0b9af1425d39
|
| 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.7-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
285a6b7dc13cc4d623bf483235db46b599cd8a15b0941f19ecda334d7cdc0211
|
|
BLAKE2b-256 checksum How to use checksums |
ba5a2e6daf406c845fba1e8709016a7318ca58e997ddd1174b7863700516bb14
|
| 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.7-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
5bef469b5b0ffd9bfa3303c30b39ec779ae29b349ceec334f2c0596de09c2a04
|
|
BLAKE2b-256 checksum How to use checksums |
afd0eb0ecd09a7b326883e833fbffe3d31d4b0e57545c47fbfb113e9cbf07961
|
| 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.7-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
19ac78111fdd57d2816573dbe08d364638339bf528c8397d7409ec2692536216
|
|
BLAKE2b-256 checksum How to use checksums |
8522baf920d17648d81ef05bc0d085adf537f0cdf9b86948bce5cef578ea20cf
|
| 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.7-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
c1d6cd3ead2bd80d8a13d59703f8b91b6bf5a43727534e81181f8b49406de344
|
|
BLAKE2b-256 checksum How to use checksums |
3a334f32488c5736687921c54bd20dcdb184558caedb7c242d88181ef6b7d999
|
| 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.7-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
72fe07efd859edc2ef0b197654a3bb1dbd319867342a2f3e1925045ea5b6219e
|
|
BLAKE2b-256 checksum How to use checksums |
eeb05edd31a278371b5abb62e0577059787519d74c971101d442ca81c8f275f6
|
| 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.7-cp310-cp310-manylinux_2_31_x86_64.whl
| Download URL | maplibre_tiles-0.2.7-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 |
a2fae0613eea7326e98188efbde17c937d14716c1c72aa1f52be89a3430e9009
|
|
BLAKE2b-256 checksum How to use checksums |
82c49103405172cb90b2b971a5b15c9802cab5835c88529b949e612b8bb16069
|
| 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}
|