-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_1.py
More file actions
41 lines (29 loc) · 1.2 KB
/
example_1.py
File metadata and controls
41 lines (29 loc) · 1.2 KB
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
from pygridmap import gridtiler
import os
#create output folder if it does not already exists
if not os.path.exists("tmp/"): os.makedirs("tmp/")
#define cell transformation function
def cell_transformation_fun(c):
#extract x and y from grid cell code
a = c['GRD_ID'].split("N")[1].split("E")
c["x"] = int(a[1])
c["y"] = int(a[0])
#delete unecessary data
del c['GRD_ID']
del c['CNTR_ID']
print("Transformation")
gridtiler.grid_transformation("assets/pop_5000m.csv", cell_transformation_fun, "tmp/pop_5000.csv")
print("Aggregation to 10 000m")
gridtiler.grid_aggregation("tmp/pop_5000.csv", 5000, "tmp/pop_10000.csv", 2, 0)
print("Aggregation to 20 000m")
gridtiler.grid_aggregation("tmp/pop_5000.csv", 5000, "tmp/pop_20000.csv", 4, 0)
print("Aggregation to 50 000m")
gridtiler.grid_aggregation("tmp/pop_5000.csv", 5000, "tmp/pop_50000.csv", 10, 0)
print("Tiling 5000m")
gridtiler.grid_tiling("tmp/pop_5000.csv", "tmp/5000", 5000)
print("Tiling 10 000m")
gridtiler.grid_tiling("tmp/pop_10000.csv", "tmp/10000", 10000)
print("Tiling 20 000m")
gridtiler.grid_tiling("tmp/pop_20000.csv", "tmp/20000", 20000)
print("Tiling 50 000m")
gridtiler.grid_tiling("tmp/pop_50000.csv", "tmp/50000", 50000)