Skip to main content

A rio-tiler plugin to encode tile array to MVT

Project description

rio-tiler-mvt

rio-tiler

A rio-tiler plugin to translate tile array to MVT (using python-vtzero).

Test Coverage Package version Downloads

More on COG Talk blog posts

Install

Requirements

rio-tiler-mvt use python-vtzero wrapper to encode point and polygons to MVT. Because VTZERO is a C++ library, python-vtzero is written in Cython, thus cython is required to compile this library.

$ pip install cython # see https://github.com/tilery/python-vtzero#requirements

$ pip install rio-tiler-mvt

Or

$ git clone http://github.com/cogeotiff/rio-tiler-mvt
$ cd rio-tiler-mvt
$ pip install -e .

Rio-tiler + Mapbox Vector tiles

API

pixel_encoder

pixels_encoder(
    data: numpy.ndarray,
    mask: numpy.ndarray,
    band_names: list = [],
    layer_name: str = "my_layer",
    feature_type: str = "point"
)

Inputs:

  • data: raster tile data to encode
  • mask: mask data
  • band_names: Raster band's names
  • layer_name: Layer name
  • feature_type: Feature type (point or polygon)

Returns:

  • mvt : Mapbox Vector Tile encoded data.

Examples:

from rio_tiler.io import COGReader
from rio_tiler_mvt import pixels_encoder

with COGReader("fixtures/test.tif") as cog
    img = cog.tile(72, 63, 7, resampling_method="nearest")
    mvt = pixels_encoder(img.data, img.mask, layer_name="test", feature_type="point")

shapes_encoder

shapes_encoder(
    data: numpy.ndarray,  # 1D array (height, width)
    mask: numpy.ndarray,
    layer_name: str = "my_layer",
    colormap: dict = {},
    class_names: dict = {}
)

Inputs:

  • data: raster tile data to encode
  • mask: mask data
  • layer_name: Layer name
  • colormap: GDAL colormap. If provided a color value will be added to the feature properties
  • class_names: Dictionary mapping pixel value with class names. If provided a name value will be added to the feature properties.

Returns:

  • mvt : Mapbox Vector Tile encoded data.

Contribution & Development

Issues and pull requests are more than welcome.

dev install

$ git clone https://github.com/cogeotiff/rio-tiler-mvt.git
$ cd rio-tiler-mvt
$ pip install -e .[dev]

pre-commit

This repo is set to use pre-commit to run isort, flake8, pydocstring, black ("uncompromising Python code formatter") and mypy when committing new code.

$ pre-commit install

Links

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

rio-tiler-mvt-0.1.0.tar.gz (65.2 kB view details)

Uploaded Source

File details

Details for the file rio-tiler-mvt-0.1.0.tar.gz.

File metadata

  • Download URL: rio-tiler-mvt-0.1.0.tar.gz
  • Upload date:
  • Size: 65.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.9

File hashes

Hashes for rio-tiler-mvt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f779efc2fb6e6795bfca145d9c7c8d1a9384788441c2baea72511ae8d0d15ad5
MD5 4fde3e4836a7bbcb1fe3eeeebe5abce5
BLAKE2b-256 0d6d7f1572186ba754cc4efd1705e845affc50fc607168e5be5706c8672a3c04

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