Last active
May 13, 2022 14:58
-
-
Save abulte/27767abd008121144447f66c7bb4ce16 to your computer and use it in GitHub Desktop.
validata-geojson-stream
This file contains hidden or 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 collections | |
import json | |
import json_stream | |
import jsonschema | |
from jsonschema import Draft7Validator | |
with open("schema_amenagements_cyclables.json") as ifile: | |
schema = json.load(ifile) | |
# get schema for one item | |
subschema = schema["properties"]["features"]["items"]["properties"]["properties"] | |
errors = collections.defaultdict(int) | |
with open("france-20220224.geojson") as f: | |
data = json_stream.load(f) | |
count = 0 | |
v = Draft7Validator(subschema) | |
for feature in data["features"].persistent(): | |
count += 1 | |
print(count) | |
props = dict(feature["properties"]) | |
for e in v.iter_errors(props): | |
errors[e.message] += 1 | |
print(errors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment