Skip to content

Instantly share code, notes, and snippets.

@zerebubuth
Created March 10, 2016 14:53
Show Gist options
  • Save zerebubuth/4cabee85c519b3889527 to your computer and use it in GitHub Desktop.
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.
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