Skip to content

Instantly share code, notes, and snippets.

@maxerickson
Last active September 25, 2017 17:54
Show Gist options
  • Save maxerickson/45860274fc4e6cbaed6bf59b3f1b4753 to your computer and use it in GitHub Desktop.
Save maxerickson/45860274fc4e6cbaed6bf59b3f1b4753 to your computer and use it in GitHub Desktop.
#!/bin/python3
import json
import os
import argparse
def make_parser():
parser = argparse.ArgumentParser(description='Clean up tags.')
parser.add_argument('input', type=str,
help='input filename')
parser.add_argument('output', type=str,
help='output filename')
return parser
if __name__=="__main__":
ap=make_parser()
args=ap.parse_args()
inf=open(args.input)
data=json.load(inf)
for feature in data["features"]:
h=feature["properties"].get("height",None)
if h:
feature["properties"]["height"]="%.1f" % float(h)
if feature["properties"]["height"]=="0.0":
del feature["properties"]["height"]
print('Removed height==0.0')
keys=list(feature["properties"].keys())
for k in keys:
if feature["properties"][k]=="":
del feature["properties"][k]
with open(args.output, 'w') as ouf:
json.dump(data,ouf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment