Last active
September 25, 2017 17:54
-
-
Save maxerickson/45860274fc4e6cbaed6bf59b3f1b4753 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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