-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexploreGeoJson.py
38 lines (32 loc) · 973 Bytes
/
exploreGeoJson.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
Query geojson files from a downloaded dataset, reading in each map-square's geojson and looking for certain objects
(used to get an overview of proportion of buildings/roads/etc in a dataset)
building
highway (road)
natural: water
water: reservoir
waterway: river
landuse: meadow
landuse: farmland
Lars Roemheld, roemheld@stanford.edu
'''
__author__ = 'Lars Roemheld'
import os, json
import getOSMmap
look_for_tag = "landuse"
nl = 0
ntag = 0
print "starting to read files"
for fn in os.listdir('.'):
if len(fn) > 5 and fn[-5:] == '.json':
if nl % 100 == 0:
print "now in file: " + fn + " #total: " + str(nl) + " #withTag: " + str(ntag)
with open(fn, 'r') as f:
map_data = json.load(f)
nl += 1
ntag += getOSMmap.osmMapHasTag(map_data, look_for_tag)
print "done"
print look_for_tag
print "total files: " + str(nl)
print "thereof with tag: " + str(ntag)
print "percentage: " + str(1.0 * ntag / nl)