Mapbox Vector Tile
Project description
Mapbox Vector Tile
==================
Installation
------------
mapbox-vector-tile is compatible with Python 2.6, 2.7, 3.2, 3.3, and 3.4. It is listed on `PyPi as 'mapbox-vector-tile'`_. The recommended way to install is via pip_:
.. code::
pip install mapbox-vector-tile
.. _PyPi as 'mapbox-vector-tile': https://pypi.python.org/pypi/mapbox-vector-tile/
.. _pip: http://www.pip-installer.org
Encoding
~~~~~~~~
Encode method expects an array of layers or atleast a single valid layer. A valid layer is a dictionary with the following keys
- name: layer name
- features: an array of features. A feature is a dictionary with the following keys:
- geometry: representation of the feature geometry in WKT or WKB
- properties: a dictionary with a few keys and their corresponding values.
.. code:: python
>>> import mapbox_vector_tile
# Using WKB
>>> mapbox_vector_tile.encode([
{
"name": "water",
"features": [
{
"geometry":"\001\003\000\000\000\001\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
"properties":{
"uid":123,
"foo":"bar",
"cat":"flew"
}
}
]
},
{
"name": "air",
"features": [
{
"geometry":"\001\003\000\000\000\001\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
"properties":{
"uid":1234,
"foo":"bar",
"cat":"flew"
}
}
]
}
])
'\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aY\n\x03air\x12\x1c\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02'
# Using WKT
>>> mapbox_vector_tile.encode([
{
"name": "water",
"features": [
{
"geometry":"POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))",
"properties":{
"uid":123,
"foo":"bar",
"cat":"flew"
}
}
]
},
{
"name": "air",
"features": [
{
"geometry":"LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)",
"properties":{
"uid":1234,
"foo":"bar",
"cat":"flew"
}
}
]
}
])
'\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aW\n\x03air\x12\x1a\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x02"\n\t\x8d\x01\xaa?\x12\x00\x00\x00\x00\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02'
Decoding
~~~~~~~~
Decode method takes in a valid google.protobuf.message Tile and returns decoded string in the following format
.. code:: python
{
layername: [
{
'geometry': 'list of points',
'properties': 'dictionary of key/value pairs',
'id': 'unique id for the given feature within the layer '
},
{
# ...
}
],
layername2: [
# ...
]
}
.. code:: python
>>> import mapbox_vector_tile
>>> mapbox_vector_tile.decode('\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aY\n\x03air\x12\x1c\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02')
{
'water': [
{
'geometry': [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]],
'properties': {
'foo': 'bar',
'uid': 123,
'cat': 'flew'
},
'id': 1
}
],
'air': [
{
'geometry': [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]],
'properties': {
'foo': 'bar',
'uid': 1234,
'balls': 'foo',
'cat': 'flew'
},
'id': 1
}
]
}
==================
Installation
------------
mapbox-vector-tile is compatible with Python 2.6, 2.7, 3.2, 3.3, and 3.4. It is listed on `PyPi as 'mapbox-vector-tile'`_. The recommended way to install is via pip_:
.. code::
pip install mapbox-vector-tile
.. _PyPi as 'mapbox-vector-tile': https://pypi.python.org/pypi/mapbox-vector-tile/
.. _pip: http://www.pip-installer.org
Encoding
~~~~~~~~
Encode method expects an array of layers or atleast a single valid layer. A valid layer is a dictionary with the following keys
- name: layer name
- features: an array of features. A feature is a dictionary with the following keys:
- geometry: representation of the feature geometry in WKT or WKB
- properties: a dictionary with a few keys and their corresponding values.
.. code:: python
>>> import mapbox_vector_tile
# Using WKB
>>> mapbox_vector_tile.encode([
{
"name": "water",
"features": [
{
"geometry":"\001\003\000\000\000\001\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
"properties":{
"uid":123,
"foo":"bar",
"cat":"flew"
}
}
]
},
{
"name": "air",
"features": [
{
"geometry":"\001\003\000\000\000\001\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\360?\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
"properties":{
"uid":1234,
"foo":"bar",
"cat":"flew"
}
}
]
}
])
'\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aY\n\x03air\x12\x1c\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02'
# Using WKT
>>> mapbox_vector_tile.encode([
{
"name": "water",
"features": [
{
"geometry":"POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))",
"properties":{
"uid":123,
"foo":"bar",
"cat":"flew"
}
}
]
},
{
"name": "air",
"features": [
{
"geometry":"LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)",
"properties":{
"uid":1234,
"foo":"bar",
"cat":"flew"
}
}
]
}
])
'\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aW\n\x03air\x12\x1a\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x02"\n\t\x8d\x01\xaa?\x12\x00\x00\x00\x00\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02'
Decoding
~~~~~~~~
Decode method takes in a valid google.protobuf.message Tile and returns decoded string in the following format
.. code:: python
{
layername: [
{
'geometry': 'list of points',
'properties': 'dictionary of key/value pairs',
'id': 'unique id for the given feature within the layer '
},
{
# ...
}
],
layername2: [
# ...
]
}
.. code:: python
>>> import mapbox_vector_tile
>>> mapbox_vector_tile.decode('\x1aJ\n\x05water\x12\x1a\x08\x01\x12\x06\x00\x00\x01\x01\x02\x02\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x03cat"\x05\n\x03bar"\x02 {"\x06\n\x04flew(\x80 x\x02\x1aY\n\x03air\x12\x1c\x08\x01\x12\x08\x00\x00\x01\x01\x02\x02\x03\x03\x18\x03"\x0c\t\x00\x80@\x1a\x00\x01\x02\x00\x00\x02\x0f\x1a\x03foo\x1a\x03uid\x1a\x05balls\x1a\x03cat"\x05\n\x03bar"\x03 \xd2\t"\x05\n\x03foo"\x06\n\x04flew(\x80 x\x02')
{
'water': [
{
'geometry': [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]],
'properties': {
'foo': 'bar',
'uid': 123,
'cat': 'flew'
},
'id': 1
}
],
'air': [
{
'geometry': [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]],
'properties': {
'foo': 'bar',
'uid': 1234,
'balls': 'foo',
'cat': 'flew'
},
'id': 1
}
]
}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mapbox-vector-tile-0.0.1.tar.gz.
File metadata
- Download URL: mapbox-vector-tile-0.0.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1962f5f965abd4f45fc4b80ced653058ce9b806c45b5a3ec53e149e2fa71b958
|
|
| MD5 |
568f7da208d69939a786c9037424f9fd
|
|
| BLAKE2b-256 |
3ef7684a2d0b39cee5e6ce59104b456217e22364670d0f5b33f4f84fba9db1ea
|
File details
Details for the file mapbox_vector_tile-0.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: mapbox_vector_tile-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
012e424030eabf9becae1f015ce9df72e397528ee04b651a42c1ab2530fba7a0
|
|
| MD5 |
20d405d7f7eb78bc1753b6d9b6f414b6
|
|
| BLAKE2b-256 |
b4e1c6c196ded5c09042cf67a795eb80e0ff2fe6d05a8f37374a470f640ad191
|