Skip to content

Commit b7c158b

Browse files
committed
remove redundant geometry attribute for project geojson files #164
1 parent 946363f commit b7c158b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mapswipe_workers/mapswipe_workers/generate_stats.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,22 @@ def csv_to_geojson_centroids(filename):
651651
def cast_datatypes_for_geojson(filename):
652652
'''
653653
Go through geojson file and try to cast all values as float, except project_id
654+
remove redundant geometry property
654655
'''
655656
filename = filename.replace('csv', 'geojson')
656657
with open(filename) as f:
657658
geojson_data = json.load(f)
658659

660+
properties = list(geojson_data['features'][0]['properties'].keys())
661+
659662
for i in range(0, len(geojson_data['features'])):
660-
for property in geojson_data['features'][i]['properties'].keys():
663+
for property in properties:
661664
if property in ['project_id', 'name', 'project_details']:
662665
# don't try to cast project_id
663666
pass
667+
elif property in ['geom']:
668+
# remove redundant geometry property
669+
del geojson_data['features'][i]['properties'][property]
664670
else:
665671
try:
666672
geojson_data['features'][i]['properties'][property] = float(geojson_data['features'][i]['properties'][property])

0 commit comments

Comments
 (0)