Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Last active July 19, 2020 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmarkoh/7d35df2e44153ef2edf6ed683a1a0b11 to your computer and use it in GitHub Desktop.
Save markmarkoh/7d35df2e44153ef2edf6ed683a1a0b11 to your computer and use it in GitHub Desktop.
import h3
import csv
import json
with open('./thor_filtered.csv', newline='') as csvfile:
line = csv.reader(csvfile, delimiter=',')
lines = 0
results = {}
for row in line:
lines += 1
if (lines == 1):
continue
lat, lng = float(row[8]), float(row[9])
hexval = h3.geo_to_h3(lat, lng, 7)
if hexval in results:
results[hexval] += 1
else:
results[hexval] = 1
hexarr = []
for val in results:
# skip the 1 off in this dataset, looks to be air combat?
count = results[val]
if count == 1 or count > 7000:
continue
obj = {}
obj['hex'] = val
obj['count'] = count
hexarr.append(obj)
print(json.dumps(hexarr, indent=2))
[
{
"hex": "87416e865ffffff",
"count": 862
},
{
"hex": "87414880bffffff",
"count": 866
},
{
...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment