-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_grid.py
More file actions
33 lines (32 loc) · 782 Bytes
/
create_grid.py
File metadata and controls
33 lines (32 loc) · 782 Bytes
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
def gridder():
# function gridder creates grid point data in geojson format
pointid = 1
lonmin, lonmax, latmin, latmax = -180, 180, -90, 90
orglatmin = latmin
stepsize = 10
while lonmin < lonmax:
gj = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [float(lonmin), float(latmin)]
},
"properties": {
"name": "Point" + str(pointid)
}
}
yield(gj)
latmin += stepsize
pointid += 1
if latmin == latmax:
latmin = orglatmin
lonmin += stepsize
# print the output in a json array
i = 0
print("[")
for g in gridder():
if i > 0:
print(",")
print(str(g))
i += 1
print("]")