Package geobuf returning NoneType when trying to convert .pbf to json

144 Views Asked by At

I am downloading a .pbf file from the following location:

https://api.mapbox.com/v4/tableau-enterprise.ctcaz7rr/4/7/5.vector.pbf?sku=101NmEGuqERal&access_token=pk.eyJ1IjoidGFibGVhdS1lbnRlcnByaXNlIiwiYSI6ImNrY29iZjN6MzA4ZzgycHF6MHd0cXhyaXoifQ.rtfFAKyzk-qMYue5C-8RVA

This returns a JSON blob as per the below:

{"bounds":[-171.5625,-55.37911,178.59375,81.093214],"center":[120.585938,23.563592,9],"created":1608167491585,"created_by_client":"studio","description":"admin2-lines_z49.mbtiles","filesize":56315904,"format":"pbf","generator":"tile-join v1.36.0","generator_options":"tippecanoe -f -o admin2-labels_z49.mbtiles -r0 -Z4 -z9 -l admin-2-labels-j admin2_label_mb_stage2.geojson; tippecanoe -f -o admin2-lines_z49.mbtiles -r0 -Z4 -z9 -l admin-2-lines admin2_mb_merge.geojson; tile-join -o admin-2-join_z9.mbtiles admin2-lines_z49.mbtiles admin2-labels_z49.mbtiles","id":"tableau-enterprise.ctcaz7rr","mapbox_logo":true,"maxzoom":9,"minzoom":4,"modified":1608167491377,"name":"admin_2_z9-9pepve","private":true,"scheme":"xyz","tilejson":"2.2.0","tiles":["https://a.tiles.mapbox.com/v4/tableau-enterprise.ctcaz7rr/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1IjoidGFibGVhdS1lbnRlcnByaXNlIiwiYSI6ImNrY29iZjN6MzA4ZzgycHF6MHd0cXhyaXoifQ.rtfFAKyzk-qMYue5C-8RVA","https://b.tiles.mapbox.com/v4/tableau-enterprise.ctcaz7rr/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1IjoidGFibGVhdS1lbnRlcnByaXNlIiwiYSI6ImNrY29iZjN6MzA4ZzgycHF6MHd0cXhyaXoifQ.rtfFAKyzk-qMYue5C-8RVA"],"type":"overlay","upload_id":"ckis5d9e5082z23phtcg5sol1","vector_layers":[{"description":"","fields":{"default":"String","id":"Number","name_de":"String","name_en":"String","name_es":"String","name_fr":"String","name_ja":"String","name_ko":"String","name_pt":"String","name_zh":"String","name_zh-Hans":"String","parent_0":"String","worldview":"String"},"id":"admin-2-labels-j","maxzoom":9,"minzoom":4,"source":"tableau-enterprise.ctcaz7rr","source_name":"admin_2_z9-9pepve"},{"description":"","fields":{"worldview":"String"},"id":"admin-2-lines","maxzoom":9,"minzoom":4,"source":"tableau-enterprise.ctcaz7rr","source_name":"admin_2_z9-9pepve"}],"version":"2","webpage":"https://a.tiles.mapbox.com/v4/tableau-enterprise.ctcaz7rr/page.html?access_token=pk.eyJ1IjoidGFibGVhdS1lbnRlcnByaXNlIiwiYSI6ImNrY29iZjN6MzA4ZzgycHF6MHd0cXhyaXoifQ.rtfFAKyzk-qMYue5C-8RVA"}

Playing around with Chrometools, I have managed to download the .pbf file locally. I am then attempting to unpack this to convert this back to geojson using geobuf as per the below:

import geobuf

with open('C:\\Users\\<mydir>\\Downloads\\5.vector.pbf', 'rb') as f:
    contents = f.read()
f.close()

my_json = geobuf.decode(contents) # Geobuf string -> GeoJSON or TopoJSON
print('********', my_json)

...however, all I am getting back from that is a NoneType object. What am I doing wrong?

Thanks

0

There are 0 best solutions below