Folium Demo Save

Using Python for basic GIS: Folium, Flask, Heroku, and open data APIs

Project README

Summary

demo/

Interactive notebooks that go into depth, with links, comments, and examples including GeoJSON/choropleths and the Walk Score API. You can click the badge to play around with the code on Google Colaboratory, but without API keys some of the live data functionality won't work.

Open In Colab

You can also view static versions on nbviewer:

tracker/

A barebones Flask app that demonstrates some basic Folium functionality using the WMATA API. This exact repository is hosted on Heroku here. It takes one of the demo examples and shows how it can be delivered through a web browser. The code is meant to showcase possibilities, not best practices. Don't judge me.

Environment

The project was developed under Python 2.7 updated to Python 3.7!

  • The webapp environment is specified in requirements.txt
    • You will need to have the WMATA_KEY environment variable set to your WMATA API key
  • The demo environment is provided in environment.yml
    • You will need to put your API keys in files demo/secrets/.wmata and demo/secrets/.walkscore

You can get a temporary guest API key for WMATA.

References

The higher level technologies used are:

  • Conda for package management
  • Git for version control
  • Heroku for web hosting
  • Jupyter for interactive Python notebooks

See the Jupyter notebook for links to documentation relevant to the demos, including Flask, Folium, and links to the APIs used.

Heroku quickstart

Option A (Suggested): Use the Python buildpack and deploy with Git.

Option B: If you end up needing a lot of packages or want to use Conda, you can try deploying with Docker.

  1. Download the Heroku CLI and sign in with heroku login.
  2. Create a Heroku application with heroku create <app_name> --buildpack heroku/python or leave the name blank to auto-generate one.
  3. Make a requirements.txt file with all dependencies for the app.
  4. Make a runtime.txt file that specifies the Python runtime version, eg. python-3.7.1.
  5. Make a Procfile that has eg. web: gunicorn --pythonpath . tracker --log-file=-.
  6. Deploy the repo to Heroku by git push heroku master. You should be able to access your app at https://<app_name>.herokuapp.com.

There is a quickstart guide available as a reference.

Debugging

heroku logs can display remote logs from your app, however heroku local will run the app at localhost:5000 and will be more useful for debugging.

  • Remember to put WMATA_KEY in the environment
  • The app will need to reach the public internet for geocoding
Open Source Agenda is not affiliated with "Folium Demo" Project. README Source: gotoariel/folium-demo
Stars
63
Open Issues
1
Last Commit
5 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating