Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coding-to-music/291600d7a84990830af878a0de9d102c to your computer and use it in GitHub Desktop.
Save coding-to-music/291600d7a84990830af878a0de9d102c to your computer and use it in GitHub Desktop.
Datasette for Polar Bears

Datasette for Polar Bears

I found an interesting looking dataset about Polar Bear ear tag tracking on a USGS website: https://alaska.usgs.gov/products/data.php?dataid=130

I deployed it as a datasette website and API here: https://polar-bears.now.sh/

Here's how I did it:

  1. Install datasette and csvs-to-sqlite:

     pip3 install datasette
     pip3 install csvs-to-sqlite
    
  2. Download the zip file:

     cd /tmp
     wget https://alaska.usgs.gov/data/polarBear/telemetry/southernBeaufortSea_2009_2011/PolarBear_Telemetry_southernBeaufortSea_2009_2011.zip
    
  3. Extract it:

     unzip PolarBear_Telemetry_southernBeaufortSea_2009_2011.zip
    
  4. Convert the CSV files into a SQLite database:

     csvs-to-sqlite USGS*.csv polar-bears.db
    
  5. Deploy it using datasette, with some metadata:

     datasette publish now /tmp/polar-bears.db \
         --title="Polar Bear Ear Tags, 2009-2011" \
         --source="USGS Alaska Science Center, Polar Bear Research Program" \
         --source_url="https://alaska.usgs.gov/products/data.php?dataid=130" \
         --name=polar-bears
    
  6. The above command outputs a URL - let's give it a nicer one:

     now alias polarbears-syhlooyyzd.now.sh polar-bears.now.sh
    

Done! The result can be seen at https://polar-bears.now.sh/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment