What format is returned by get_tile ?
Hello,
I used you library to implement a VectorTile server from GeoJSON however I've been unable to display the resulting tile with OpenLayers. I get a dict with keys likes minX, maxY... and I have no idea what format this is. I tried MVP, GeoJSON and TopoJSON in OpenLayers, none managed to load these tiles.
Thanks
It should comply with the vector-tile-spec that can be found here: https://github.com/mapbox/vector-tile-spec/blob/master/README.md. I'm not sure about the viewers that support this format, though, and someone more qualified might be able to help. The JavaScript package reference https://github.com/mapbox/mapbox-gl-js as an example, maybe that helps.
Hello,
I'm not sure about that, MVT file are supposed to be protobuf, or maybe I should then encode the dict payload to protobuf ?
Thanks
Seems I misunderstood the spec. This is a python port of the javascript equivalent geojson-vt which states:
Resulting tiles conform to the JSON equivalent of the vector tile specification.
I'm not sure, but in theory it should be possible to encode in protobuf to be conformant with the spec.
@Murthy10 I have the same question... I'm not quite sure how to get from the not-quite-GeoJSON but also not-quite-vt-protobuf output to something I can load as a real honest vector tile.... this code illustrates I believe the same "what now?" question that has us scratching our heads
# This is a large half-gigabyte FeatureCollection, load once at startup
geojson_path = 'big-featurecollection.geojson'
geojson_data = get_json(geojson_path)
mvt = geojson2vt(geojson_data, {'maxZoom': 20})
@app.route(f"{URL_BASE}/vector_tiles/<int:z>/<int:x>/<int:y>")
def vector_tiles(z=None, x=None, y=None, geojson_key=None):
tile_dict = mvt.get_tile(z, x, y)
# So.... Now what????
#
# OK, I don't think /this/ is right.... this JSON is now a LOT
# more like the spec in vector_tile.proto but I'm missing some
# step to convert this to an actual binary ProtoBuf, but tile_dict
# is still not suitable to call google.protobuf.json_format.ParseDict
# according to the vector_tile.proto spec.... so how do we get
# from point A to something mapboxGL will see as a binary protobuf MVT???
return jsonify(tile_dict)
Any hints? :-)
@Murthy10 I have the same question... I'm not quite sure how to get from the not-quite-GeoJSON but also not-quite-vt-protobuf output to something I can load as a real honest vector tile.... this code illustrates I believe the same "what now?" question that has us scratching our heads
# This is a large half-gigabyte FeatureCollection, load once at startup geojson_path = 'big-featurecollection.geojson' geojson_data = get_json(geojson_path) mvt = geojson2vt(geojson_data, {'maxZoom': 20}) @app.route(f"{URL_BASE}/vector_tiles/<int:z>/<int:x>/<int:y>") def vector_tiles(z=None, x=None, y=None, geojson_key=None): tile_dict = mvt.get_tile(z, x, y) # So.... Now what???? # # OK, I don't think /this/ is right.... this JSON is now a LOT # more like the spec in vector_tile.proto but I'm missing some # step to convert this to an actual binary ProtoBuf, but tile_dict # is still not suitable to call google.protobuf.json_format.ParseDict # according to the vector_tile.proto spec.... so how do we get # from point A to something mapboxGL will see as a binary protobuf MVT??? return jsonify(tile_dict)Any hints? :-)
did you managed to figuring it out? I am stuck here.
old issue but still relevant: here for reference you need to encode as bpf with something like this: https://github.com/DenysMoskalenko/vt2pbf