-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistics.py
52 lines (39 loc) · 1.55 KB
/
statistics.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
import csv
import requests
import os
from pathlib import Path
import convex_hull as ch
import is_georeferenced as gr
stukIds = sys.argv[1]
imageFileDirectory = sys.argv[2]
outputDirectory = sys.argv[3]
if not os.path.isfile(stukIds):
print('No file for stukIds present ({})'.format(stukIds))
if not os.path.isdir(outputDirectory):
os.makedirs(outputDirectory)
with open(stukIds, 'r') as idFile:
reader = csv.reader(idFile)
with open(outputDirectory+'/statistics.csv', 'w') as outputCsv:
writer = csv.writer(outputCsv)
writer.writerow(['StukId', 'Wit %', 'InVlaanderen', 'Bestandsgrootte'])
for [id] in reader:
print(" => Executing for id {}".format(id))
if not os.path.isfile(imageFileDirectory+'/'+id+'.tif'):
print("File {} not present".format(id))
continue
data=[id]
print("Calculate convex hull")
try:
data.append(",".join(str(ch.convex_hull(imageFileDirectory+'/'+id+'.tif', debug=True)).split('.')))
except Exception as e:
data.append(e)
print(" => Calculated convex hull")
print("Calculate georefence")
data.append(str(gr.inVlaanderen(imageFileDirectory+'/'+id+'.tif')))
print(" => Calculated convex hull")
print("Calculate filesize")
data.append(str(os.path.getsize(imageFileDirectory+'/'+id+'.tif')))
print(" => Calculated filesize")
writer.writerow(data)
outputCsv.flush()