tilery / python-vtzero

Experimental Cython wrapper around vtzero

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-vtzero

Experimental Python wrapper of vtzero a minimalist vector tile decoder and encoder in C++

Status Packaging status

Requirements

  • Python >= 3.8
  • gcc/clang++ >= 4.5 (C++11)

Install

You can install python-vtzero using pip

$ python -m pip install vtzero

or install from source

$ git clone https://github.com/tilery/python-vtzero
$ cd python-vtzero

# Download vendor submodules (protozero, mvt-fixtures, vtzero)
$ git submodule update --init

# Compile Cython module
$ python setup.py build_ext --inplace
$ python -m pip install -e .

Example

A complete example can be found here

from vtzero.tile import VectorTile, Tile, Layer, Point

# Create MVT
tile = Tile()

# Add a layer
layer = Layer(tile, b'my_layer')

# Add a point
feature = Point(layer)
feature.add_points(1)
feature.set_point(10, 10)
feature.add_property(b'foo', b'bar')
feature.add_property(b'x', b'y')
feature.commit()

# Encode mvt
data = tile.serialize()

About

Experimental Cython wrapper around vtzero


Languages

Language:Python 49.5%Language:Cython 49.3%Language:Makefile 1.2%