Skip to content

Instantly share code, notes, and snippets.

@osteth
Created May 3, 2017 15:46
Show Gist options
  • Save osteth/6d3877759259f80a34fb5d7dbb9492ab to your computer and use it in GitHub Desktop.
Save osteth/6d3877759259f80a34fb5d7dbb9492ab to your computer and use it in GitHub Desktop.
pulls latitude, longitude and calculates a radius based on scan/track values to make a list of circles for plotting on the map.
#!/usr/bin/python3
import json
def LLR():
table = []
llr_table = []
with open('MODIS_C6_Global_24h.json', 'r') as data_file:
for line in data_file:
try:
j = line.split('|')[-1]
table.append(json.loads(j))
except ValueError:
print("Bad Json File!")
continue
for row in table:
lon = float(row['longitude'])
lat = float(row['latitude'])
scan = row['scan']
track = row['track']
radius = (float(scan) * float(track) / 2) * 750 #kilometers
radius = round(radius, 2) #round to two decimal places
stroke_color = "FF0000"
fill_color = "FF0000"
llr_table.append([{
'center': {'lng': lon,
'lat': lat},
'radius': radius,
'infobox': 'MODIS Wildfire Detection Area'}])
llr_table.append(',')
return llr_table
LLRTABLE = LLR()
print(len(LLRTABLE))
#print(LLRTABLE[0])
i = 0
while i < len(LLRTABLE):
print(LLRTABLE[i])
i+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment