tile-tools


Nametile-tools JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryA collection of tools for navigating Mapbox tiles.
upload_time2023-01-31 21:22:51
maintainer
docs_urlNone
authorJoe Nudell
requires_python>=3.10,<3.12
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tile Tools

[![Python Tests](https://github.com/biglocalnews/tile-tools/actions/workflows/pytest.yaml/badge.svg)](https://github.com/biglocalnews/tile-tools/actions/workflows/pytest.yaml)
[![Python Lint](https://github.com/biglocalnews/tile-tools/actions/workflows/pylint.yaml/badge.svg)](https://github.com/biglocalnews/tile-tools/actions/workflows/pylint.yaml)

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](https://github.com/mapbox/tilebelt/).

There are some minor differences in the API.
See the [submodule readme](tile_tools/tilebelt/README.md) 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`](https://github.com/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](tile_tools/cover/README.md) 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:
```zsh
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`.

```zsh
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`:

```zsh
poetry install --with dev
poetry run pre-commit install
```

### Tests

```zsh
poetry run pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "tile-tools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "Joe Nudell",
    "author_email": "jnu@stanford.edu",
    "download_url": "https://files.pythonhosted.org/packages/b4/a5/1dafe766a26e0aaca6826093983dd8adab36c9ad6d678ce8fcc78fcf9981/tile_tools-0.1.2.tar.gz",
    "platform": null,
    "description": "# Tile Tools\n\n[![Python Tests](https://github.com/biglocalnews/tile-tools/actions/workflows/pytest.yaml/badge.svg)](https://github.com/biglocalnews/tile-tools/actions/workflows/pytest.yaml)\n[![Python Lint](https://github.com/biglocalnews/tile-tools/actions/workflows/pylint.yaml/badge.svg)](https://github.com/biglocalnews/tile-tools/actions/workflows/pylint.yaml)\n\nCollection of tools useful for navigating Mapbox (and similar) tiles.\n\nMost of these tools were written by Mapbox in JavaScript. I've ported them into Python with minimal modification.\n\n\n## Contents\n\n### `tilebelt`\n\nUtility functions for working with tiles.\n\nThis is a complete Python port of Mapbox's [@mapbox/tilebelt](https://github.com/mapbox/tilebelt/).\n\nThere are some minor differences in the API.\nSee the [submodule readme](tile_tools/tilebelt/README.md) for more details.\n\n### `cover`\n\nGiven a GeoJSON Geometry and a zoom level, generate the minimal set of Mapbox `(x, y, zoom)` tiles that cover this geometry.\n\nThis is a re-implementation of Mapbox's [`@mapbox/tile-cover`](https://github.com/mapbox/tile-cover/).\nThe implementation started out as a port, however the originally library is not passing all of its own tests.\nThe API has been re-implemented here with a slightly different approach, and all of the equivalent tests are now passing.\n\nSee [submodule readme](tile_tools/cover/README.md) for details.\n\n### `coords`\n\n#### `coords.tilecoords2lnglat`\n\nTransform Mapbox's relative tile `(x, y)` coordinates into longitude/latitude degrees.\n\n\n### `distance`\n\n#### `distance.haversine`\n\nCompute the distance between two points on the globe using the haversine formula.\n\n## Rendering\n\nFor debugging and general interest, the cover algorithm can be visualized with the `scripts/render.py` script.\n\nIt requires that `gdal` and `ImageMagick` are installed. Then, run:\n```zsh\npoetry install --with render\n```\n\nAn example usage is rendering the `degenring` test fixture at zooms 1-14.\nThe output will be stored as a GIF in `render.gif`.\n\n```zsh\ncat tests/fixtures/degenring.geojson | poetry run python scripts/render.py --zmin 1 --zmax 13 --out render.gif\n```\n\n## Development\n\nSet up the environment with `poetry`:\n\n```zsh\npoetry install --with dev\npoetry run pre-commit install\n```\n\n### Tests\n\n```zsh\npoetry run pytest\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A collection of tools for navigating Mapbox tiles.",
    "version": "0.1.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "36be1a63eb0840de3044fc2f2a6f6fca651c9c541d5f5314fd029f5dfb3ab373",
                "md5": "10061d631c036160588b92ecef68102b",
                "sha256": "2379f0613a3b1ce8213b4bb85fc53f13b170133b775ec3e597207c9376278666"
            },
            "downloads": -1,
            "filename": "tile_tools-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "10061d631c036160588b92ecef68102b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.12",
            "size": 20232,
            "upload_time": "2023-01-31T21:22:50",
            "upload_time_iso_8601": "2023-01-31T21:22:50.502016Z",
            "url": "https://files.pythonhosted.org/packages/36/be/1a63eb0840de3044fc2f2a6f6fca651c9c541d5f5314fd029f5dfb3ab373/tile_tools-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4a51dafe766a26e0aaca6826093983dd8adab36c9ad6d678ce8fcc78fcf9981",
                "md5": "1d91c711f2ee6d023d3706f1d7b1c15b",
                "sha256": "d92dcbd04fd1109a60c65e2ad64096e29b9fa775ac44df3023e69535bfeb1caa"
            },
            "downloads": -1,
            "filename": "tile_tools-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1d91c711f2ee6d023d3706f1d7b1c15b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.12",
            "size": 16241,
            "upload_time": "2023-01-31T21:22:51",
            "upload_time_iso_8601": "2023-01-31T21:22:51.959848Z",
            "url": "https://files.pythonhosted.org/packages/b4/a5/1dafe766a26e0aaca6826093983dd8adab36c9ad6d678ce8fcc78fcf9981/tile_tools-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-31 21:22:51",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "tile-tools"
}
        
Elapsed time: 0.04459s