A collection of tools for navigating Mapbox tiles.
Project description
Tile Tools
Collection of tools useful for navigating Mapbox (and similar) tiles.
Most of these tools were written by Mapbox in JavaScript. I've ported them into Python with minimal modification.
Contents
tilebelt
Utility functions for working with tiles.
This is a complete Python port of Mapbox's @mapbox/tilebelt.
There are some minor differences in the API. See the submodule readme for more details.
cover
Given a GeoJSON Geometry and a zoom level, generate the minimal set of Mapbox (x, y, zoom)
tiles that cover this geometry.
This is a re-implementation of Mapbox's @mapbox/tile-cover
.
The implementation started out as a port, however the originally library is not passing all of its own tests.
The API has been re-implemented here with a slightly different approach, and all of the equivalent tests are now passing.
See submodule readme for details.
coords
coords.tilecoords2lnglat
Transform Mapbox's relative tile (x, y)
coordinates into longitude/latitude degrees.
distance
distance.haversine
Compute the distance between two points on the globe using the haversine formula.
Rendering
For debugging and general interest, the cover algorithm can be visualized with the scripts/render.py
script.
It requires that gdal
and ImageMagick
are installed. Then, run:
poetry install --with render
An example usage is rendering the degenring
test fixture at zooms 1-14.
The output will be stored as a GIF in render.gif
.
cat tests/fixtures/degenring.geojson | poetry run python scripts/render.py --zmin 1 --zmax 13 --out render.gif
Development
Set up the environment with poetry
:
poetry install --with dev
poetry run pre-commit install
Tests
poetry run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tile_tools-0.1.2.tar.gz
.
File metadata
- Download URL: tile_tools-0.1.2.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d92dcbd04fd1109a60c65e2ad64096e29b9fa775ac44df3023e69535bfeb1caa |
|
MD5 | 1d91c711f2ee6d023d3706f1d7b1c15b |
|
BLAKE2b-256 | b4a51dafe766a26e0aaca6826093983dd8adab36c9ad6d678ce8fcc78fcf9981 |
File details
Details for the file tile_tools-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: tile_tools-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2379f0613a3b1ce8213b4bb85fc53f13b170133b775ec3e597207c9376278666 |
|
MD5 | 10061d631c036160588b92ecef68102b |
|
BLAKE2b-256 | 36be1a63eb0840de3044fc2f2a6f6fca651c9c541d5f5314fd029f5dfb3ab373 |