-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_bboxes2.py
47 lines (38 loc) · 1.03 KB
/
load_bboxes2.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
'''
to calculate a geohash for the mid point of the bounding box
to write out the index and geohash to a file on disk for further processing
SMDE
18/11/15
'''
import csv
import geohash
#import riak
#import pickle
outfile=open("boxes-and-hashes.csv",'wb')
#myc=riak.RiakClient(pb_port=8087, protocol='pbc')
#print myc
#myboxbucket=myc.bucket('bboxes', bucket_type="osd")
#print myboxbucket
#myhashbucket=myc.bucket('geohashes', bucket_type="osd")
#print myhashbucket
with open('all-bboxes2.csv', 'rb') as csvfile:
bboxreader=csv.reader(csvfile)
for row in bboxreader:
index=str(row[0])
# maxlong=float(row[1])
# maxlat=float(row[2])
# minlong=float(row[3])
# minlat=float(row[4])
midlat=float(row[5])
midlong=float(row[6])
print midlat,midlong
gh=geohash.encode(midlat,midlong)
print index, gh, "\n"
# print index, row[1:5]
# key1=myhashbucket.new(index,data=gh)
# key1.store()
# bcoords=row[1:5]
# key2=myboxbucket.new(index,data=pickle.dumps(bcoords))
# key2.store()
outfile.write(index+","+gh+"\n")
outfile.close()