Vector Tile Tools
A set of classes for managing tiles of geospatial vector data
Installation and Unittests
Install via pip:
pip install vectortile
Source:
$ git clone https://github.com/SkyTruth/vectortile.git
$ cd vectortile
$ pip install -r requirements.txt
$ nosetests
$ python setup.py install
TypedMatrix
TypedMatrix is a binary coded format optimized for delivering large amounts of tabular data from a web server to a javascript client without the need for parsing in javascript on the client side.
The vectortile.TypedMatrix module provides functions to read and write typed-matrix formatted strings.
Format Details
A TypedMatrix is a packed 2 dimensional array of typed values suitable for typecasting to a set of javascript arrays. Currently two fundamental data types are supported:
- Int32
- Float32
Special handling is provided for converting datetime values to Float32. The format includes a header containing a json object, which can contain arbitrary content. The header must contain at least:
- length: indicated the number of rows in the data section
- cols: an array of column definitions. The length of this array indicates the number of columns in each row
For example, a TypedMatrix with 2 rows and 3 columns:
{
'length': 2,
'cols': [
{
'type': 'Float32',
'name': 'float'
},
{
'type': 'Int32',
'name': 'int'
},
{
'type': 'Float32',
'name': 'timestamp'
}
]
}
Usage Examples
>>> from vectortile import TypedMatrix
>>> from datetime import datetime
>>> from pprint import pprint
# Create two rows of 3 columns each: int, float and datetime
>>> data = [{'int':1, 'float':1.0, 'timestamp': datetime(2014,1,1)}]
>>> data.append ({'int':2, 'float':2.0, 'timestamp':datetime(2014,1,2)})
>>> t_str = TypedMatrix.pack(data)
# Typedmatrix is now coded as a binary string, packed row-wise
>>> t_str
'tmtx\x01\x00\x00\x00r\x89\x00\x00\x00{"length": 2, "cols": [{"type": "Float32", "name": "float"}, {"type": "Int32", "name": "int"}, {"type": "Float32", "name": "timestamp"}]}\x00\x00\x80?\x01\x00\x00\x00\x8d\xa5\xa1S\x00\x00\x00@\x02\x00\x00\x00 \xa8\xa1S'
>>> header, data = TypedMatrix.unpack(t_str)
>>> pprint(header)
{
'cols': [
{
'name': 'float',
'type': 'Float32'
},
{
'name': 'int',
'type': 'Int32'
},
{
'name': 'timestamp',
'type': 'Float32'
}
],
'length': 2
}
>>> pprint(data)
[
{
'float': 1.0,
'int': 1,
'timestamp': 1388534431744.0
},
{
'float': 2.0,
'int': 2,
'timestamp': 1388620808192.0
}
]
# Pack data column-wise
>>> TypedMatrix.pack(data,orientation='columnwise')
'tmtx\x01\x00\x00\x00c\x89\x00\x00\x00{"length": 2, "cols": [{"type": "Float32", "name": "float"}, {"type": "Int32", "name": "int"}, {"type": "Float32", "name": "timestamp"}]}\x00\x00\x80?\x00\x00\x00@\x01\x00\x00\x00\x02\x00\x00\x00\x8d\xa5\xa1S \xa8\xa1S'
>>> header, data = TypedMatrix.unpack(t_str)
>>> pprint(header)
{
'cols': [
{
'name': 'float',
'type': 'Float32'
},
{
'name': 'int',
'type': 'Int32'
},
{
'name': 'timestamp',
'type': 'Float32'
}
],
'length': 2
}
>>> pprint(data)
[
{
'float': 1.0,
'int': 1,
'timestamp': 1388534431744.0
},
{
'float': 2.0,
'int': 2,
'timestamp': 1388620808192.0
}
]
Javascript Example
Metadata
Release files for vectortile 1.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vectortile-1.4.1.tar.gz | 11.5 kB | Without provenance | Details |
Release files / vectortile-1.4.1.tar.gz
| Download URL | vectortile-1.4.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69a6095bc05dd4459188bc73094c20a9a749febbba0c5c608b5698211f94ae2f
|
|
BLAKE2b-256 checksum How to use checksums |
c66bb3d1153a9e0314dcd602711ccccf8ba4039c58e60db5c68ff2ad7b73cdd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/2.7.17
|
Security for vectortile 1.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.