Skip to main content

helps handling tile pyramids

Project description

Tilematrix handles geographic web tiles and tile pyramids.

https://badge.fury.io/py/tilematrix.svg https://travis-ci.org/ungarj/tilematrix.svg?branch=master https://coveralls.io/repos/github/ungarj/tilematrix/badge.svg?branch=master https://img.shields.io/pypi/pyversions/mapchete.svg

The module is designed to translate between tile indices (zoom, row, column = ZYX) and map coordinates (e.g. latitute, longitude).

Tilematrix supports metatiling and tile buffers. Furthermore it makes heavy use of shapely and it can also generate Affine objects per tile which facilitates working with rasterio for tile based data reading and writing.

It is very similar to mercantile but besides of supporting spherical mercator tile pyramids, it also supports geodetic (WGS84) tile pyramids.

Installation

Use pip to install the latest stable version:

pip install tilematrix

Manually install the latest development version

pip install -r requirements.txt
python setup.py install

Documentation

CLI

This package ships with a command line tool tmx which provides the following subcommands:

  • bounds: Print bounds of given Tile.

  • bbox: Print bounding box geometry of given Tile.

  • tile: Print Tile covering given point.

  • tiles: Print Tiles covering given bounds.

Geometry outputs can either be formatted as WKT or GeoJSON. For example the following command will print a valid GeoJSON representing all tiles for zoom level 1 of the geodetic WMTS grid:

$ tmx -f GeoJSON tiles -- 1 -180 -90 180 90
{
  "type": "FeatureCollection",
  "features": [
    {"geometry": {"coordinates": [[[-90.0, 0.0], [-90.0, 90.0], [-180.0, 90.0], [-180.0, 0.0], [-90.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 0, "row": 0, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[0.0, 0.0], [0.0, 90.0], [-90.0, 90.0], [-90.0, 0.0], [0.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 1, "row": 0, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[90.0, 0.0], [90.0, 90.0], [0.0, 90.0], [0.0, 0.0], [90.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 2, "row": 0, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[180.0, 0.0], [180.0, 90.0], [90.0, 90.0], [90.0, 0.0], [180.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 3, "row": 0, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[-90.0, -90.0], [-90.0, 0.0], [-180.0, 0.0], [-180.0, -90.0], [-90.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 0, "row": 1, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[0.0, -90.0], [0.0, 0.0], [-90.0, 0.0], [-90.0, -90.0], [0.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 1, "row": 1, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[90.0, -90.0], [90.0, 0.0], [0.0, 0.0], [0.0, -90.0], [90.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 2, "row": 1, "zoom": 1}, "type": "Feature"},
    {"geometry": {"coordinates": [[[180.0, -90.0], [180.0, 0.0], [90.0, 0.0], [90.0, -90.0], [180.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 3, "row": 1, "zoom": 1}, "type": "Feature"}
  ]
}

Print WKT representation of tile 4 15 23:

$ tmx bbox 4 15 23
POLYGON ((90 -90, 90 -78.75, 78.75 -78.75, 78.75 -90, 90 -90))

Also, tiles can have buffers around called pixelbuffer:

$ tmx --pixelbuffer 10 bbox 4 15 23
POLYGON ((90.439453125 -90, 90.439453125 -78.310546875, 78.310546875 -78.310546875, 78.310546875 -90, 90.439453125 -90))

Print GeoJSON representation of tile 4 15 23 on a mercator tile pyramid:

$ tmx -output_format GeoJSON -grid mercator bbox 4 15 15
{"type": "Polygon", "coordinates": [[[20037508.342789203, -20037508.3427892], [20037508.342789203, -17532819.799940553], [17532819.799940553, -17532819.799940553], [17532819.799940553, -20037508.3427892], [20037508.342789203, -20037508.3427892]]]}

License

MIT License

Copyright (c) 2015, 2016, 2017 EOX IT Services

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tilematrix-2022.3.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

tilematrix-2022.3.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file tilematrix-2022.3.0.tar.gz.

File metadata

  • Download URL: tilematrix-2022.3.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tilematrix-2022.3.0.tar.gz
Algorithm Hash digest
SHA256 cc7c28faee8a6949dedaeb37dc0a3739cfa5e64a164eee0eb7558e2ce9b2ef16
MD5 cfdb39351a20f8b5de3d8d3ff0d1f98a
BLAKE2b-256 c82fe39e60ed7226f08ca9bb443f04057c5cdd6baa0b4878e85867ab3eff530c

See more details on using hashes here.

File details

Details for the file tilematrix-2022.3.0-py3-none-any.whl.

File metadata

  • Download URL: tilematrix-2022.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tilematrix-2022.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13d9938cd39850ddb8ef39dfbf3f7b44d4de8cb76422d1edd99897d64f5d7be7
MD5 e1140aab660f9483ab7de2032e82de8d
BLAKE2b-256 2aaf003b045120561d92cdd1cf92eb51768f334fd607b23da8b42afc2bc9d102

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page