Skip to content

Instantly share code, notes, and snippets.

@hugoledoux
Last active October 13, 2023 11:46
Show Gist options
  • Save hugoledoux/a60f60cdbd5c762f51ad2bc7a5da3027 to your computer and use it in GitHub Desktop.
Save hugoledoux/a60f60cdbd5c762f51ad2bc7a5da3027 to your computer and use it in GitHub Desktop.
3dbag api fetch
import urllib.request
import json
import sys
# myurl = "http://localhost:3200//collections/pand/items/NL.IMBAG.Pand.1655100000500568"
myurl = "http://localhost:3200//collections/pand/items?bbox=75900.011,447000.034,76000.011,447200.034"
# myurl = "http://localhost:3200//collections/pand/items?bbox=75877.011,446130.034,92446.593,460259.369"
try:
with urllib.request.urlopen(myurl) as f:
j = json.loads(f.read().decode('utf-8'))
sys.stdout.write(json.dumps(j["metadata"]) + "\n")
if "feature" in j:
sys.stdout.write(json.dumps(j["feature"]) + "\n")
if "features" in j:
for f in j["features"]:
sys.stdout.write(json.dumps(f) + "\n")
except:
s = "oupsie"
raise Exception(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment