Created
March 10, 2016 14:53
-
-
Save zerebubuth/4cabee85c519b3889527 to your computer and use it in GitHub Desktop.
Test program to transcode a GeoJSON tile into MVT using the mapbox_vector_tile library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from shapely.geometry import mapping, shape | |
import sys | |
from mapbox_vector_tile import encode | |
geojson = json.load(open(sys.argv[1])) | |
layers = [] | |
for name, featurecollection in geojson.iteritems(): | |
features = [] | |
for f in featurecollection['features']: | |
props = f['properties'] | |
fid = f['id'] | |
geom = shape(f['geometry']) | |
features.append(dict(geometry=geom, properties=props, id=fid)) | |
layers.append(dict(features=features,name=name)) | |
x = encode(layers) | |
print len(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment