#!/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 | |
loading 20k +/- circles onto a map is proving to be a difficult task. hitting computing power limitations. were going to have to refactor how we are doing this if its ever going to work on a cell phone.
Project Firewatch API is Live at: http://45.32.218.91:5001/api/
Fire Mapping service prototype is live at http://45.32.218.91:5000/fullmap
just finished the project video
Dutch completed the database for MODIS's active fire data!
import csv | |
import json | |
import click | |
@click.group() | |
def cli(*args, **kwargs): | |
"""Command line utility to easily convert .csv data over to .json data. This utility was built for the NASA space apps challenge and is defaulted | |
to be used with cron to pull in data from https://earthdata.nasa.gov/earth-observation-data/near-real-time/firms/active-fire-data convert it to json | |
and load it into a database to overcome the lack of a useable api for this data. | |
Usage: python3 csv-json.py convert -i <input file path> -o <output file path>""" | |
pass | |
@click.command(help='Covert data from csv to json.') | |
@click.option('--input', '-i', default='MODIS_C6_Global_24h.csv', help='--input , -i Sets the file that is to be converted') | |
@click.option('--output', '-o', default='MODIS_C6_Global_24h.json', help='--output, -o, Sets the name of the output.') | |
def convert(input, output): | |
csvfile = open(input, 'r') | |
jsonfile = open(output, 'w') | |
reader = csv.DictReader( csvfile) | |
for row in reader: | |
json.dump(row, jsonfile) | |
jsonfile.write('\n') | |
cli.add_command(convert) | |
if __name__ == '__main__': | |
cli() |
Github is up and running https://github.com/osteth/project-firewatch
Problem #1 NASA fire data doesn't have an API. time to build one....
Just got to the STEAM WORKS, its a pretty cool space for the challenge! getting computers and everything set up with the team and starting to BUILD!!
SpaceApps is a NASA incubator innovation program.