This project explores how wildfires have affected Australia over time through data visualizations, including interactive time series charts, plots and a map. Visit the website to learn more.
This project incorporates open data from a number of sources, including data captured by NASA satellites and various wildfire and climate data. More information about the sources and the data itself can be found in the Data page in the docs
folder.
This README includes background information about the project and steps on how to set up the application locally.
- Flask, a Python micro web framework used to run the application.
- MongoDB, a NoSQL database for storing the data locally.
- MongoDB Atlas, for storing the data in the cloud.
- Heroku, for running the dashboard in the cloud.
- Jupyter Notebook, for running Python code within a larger document.
- Python, including packages like pandas and Beautiful Soup.
- D3.js, a JavaScript data visualization library.
- d3-timeseries, a library for building time series charts.
- Leaflet, a JavaScript library for building interactive maps.
Download or clone this repository.
The data for this project is stored in a MongoDB database.
Background information on the Data sources can be found on the website, and a detailed list of fields and data types for each collection can be found in the Data page in docs
.
To load the data into a local database, perform these steps:
-
Start MongoDB locally by running
mongod
from Git Bash/Terminal. -
Launch a Jupyter Notebook from Git Bash/Terminal (by running
jupyter notebook
). Note that you will likely need to install some packages likepandas
,Beautiful Soup
,pymongo
, andnumpy
to get the notebooks up and running. Open and run: -
Verify that the data is inserted into the database properly by opening MongoDB from Git Bash/Terminal or using a program like MongoDB Compass and looking for the australia_fire_db database.
The API and the application for this project are built using the Flask framework. To start a Flask server locally:
- Activate a Python virtual environment that has the appropriate packages installed, as shown in the following example:
conda activate PythonData
-
Navigate to the application folder.
-
Run the following command:
python app.py
This starts the Flask server on port 5000. You can then copy and paste the Flask URL into your browser to see the locally-hosted application in action.
-
The visualizations for this project are powered using the API endpoints. Information about the different endpoints can be found on the website and in the
docs
. -
Here's an example of how to retrieve data from the
fires_modis
API endpoint usingd3
:
const url = "https://australia-fire-api-dashboard.herokuapp.com/api/v1.0/fires_modis"
d3.json(url).then(data => {
console.log(data);
});
- You can build on this work by creating your own visualizations using the API. Examples for how to integrate the data retrieved from the API into visualizations including charts and maps can be found in
static/js
.
To view the live bushfire map locally:
- Create and save a
config.py
file in the root directory within the application folder of this repository. - Add the following line to the
config.py
file:
API_KEY = "your_key_here"
Replace your_key_here
with your Mapbox API key. More information on Mapbox API keys can be found on the Mapbox website.
The application is deployed to Heroku. It is currently hosted at https://australia-fire-api-dashboard.herokuapp.com/.
To get started, check out the official instructions for setting up an app on Heroku.
Note: If you add a Python package to the app, make sure you add that package to the requirements.txt file in the root directory of your version of the project.
To deploy a branch from Heroku:
- Push your changes to the branch you want to deploy.
- Log into Heroku and go to the Deploy tab for the australia-fire-api-dashboard app.
- Scroll all the way to the bottom to the Manual Deploy section.
- Choose a branch to deploy from the dropdown (it will most likely be the master branch).
- Click Deploy Branch.
You are welcome to fork this repo and build upon this work under the terms of an MIT license.