Location Map Filters

Generated historical data is sent to community-data/locations/datacommons.

1.) countries.csv for our country selection filters and tabulator sample:
     Data Scale: Population (in Millions), Land Area (in Thousand Sq Miles), CO2 Emissions (in Thousand Metric Tonnes)
     countries-full.csv has data in its original scale. - Both are generated from MapFilters Colab - Abhishek L

2.) us-states.csv for our state selection filters:
     Data Scale: Population (in Thousands), Land Area (in Thousand Sq Miles), CO2 and Methane Emissions (in Thousand Metric Tonnes)
     us-states-full.csv has data in its original scale. - Both are generated from MapFilters Colab - Abhishek L

3.) us-counties.csv for our county selection filters:
     Data Scale: Population (in Thousands), Land Area (in Sq Miles), CO2 and Methane Emissions (in Thousand Metric Tonnes)
     us-counties-full.csv has data in its original scale. - Both are generated from MapFilters Colab - Abhishek L

MapFilters Colab:
This CoLab stores the data of the latest available year for Population and Emissions (CO2 and Methane) on us-counties, us-states and countries level for use in top nav map filters. - Abhishek L

StateFilter Colab:
This CoLab stores the historic data of all available years for Population and Emissions on us-counties, us-states and countries level. - Abhishek L

DONE: Output countries.csv file with 2-char country codes and similar columns to us-states.csv. - Abhishek L

TO DO: Create a GitHub Action for our State Filters CoLab.
Run annually for both states and countries.

DONE: Document how to add a private Github token to push from CoLab. Documented below. - Ivy

Also see our UN Goal Timelines Javascript API display and Python API Data Pull

Previous: State Carbon Comparison

Data merged for Carbon Cycle - State Comparison within apps/js/bc.js

The original BeyondCarbon.org state comparison data seems to be removed from their site.

BeyondCarbon.org data was originally pulled into fused/result.json by beyond-carbon-scraper


Push files from a Colab to Github

Step 1: Retrieve GitHub Personal Token

NOTE: It may take 5 to 10 minutes for your token to become available.
Tokens with "no expiration date" seem to still expire after a month, so you'll need to regenerate.

Create a fine-grained token for one repo:

Generate a Fine-Grained Token.
In your GitHub account, navigate to Settings (upper right menu), then to Developer settings (lower left). Under "Personal access tokens" choose Fine-grained tokens.

Set 3 permissions for 1 of your repositories
Contents: Read and write
Deployments: Read and write
Metadata: Read-only (gets set automatically)

Store the Token in Colab
Place the token in the Colab step that sends report output to the repo.

Or save the token in the Colab notebook's Secrets section as YOUR_COLAB_TOKEN_SECRET_NAME or ModelEarth in the StatesFilter Colab.

Ensure that the notebook has access to this secret.

Step 2: Install Git and Set Up User Information

Install Git:

    !apt-get install git

Retrieve Colab Token Secret:

    from google.colab import userdata
    token = userdata.get('YOUR_COLAB_TOKEN_SECRET_NAME')

Set Up User Information:

    USERNAME = "YOUR_USERNAME"
    REPO_NAME = "YOUR_TARGET_REPO"
    EMAIL = "YOUR_EMAIL_ADDRESS"

Configure Git Global Settings:

    !git config --global user.email {EMAIL}
    !git config --global user.name {USERNAME}

Step 3: Specify Target Repo url and Clone

Specify the Repository URL:
Construct the repository URL with your GitHub token for authentication. This variable needs to be in the same code block with user information variables.

    repo_url = f"https://{token}@github.com/{USERNAME}/{REPO_NAME}.git"

Clone the repo

    !git clone {repo_url}

Step 4: Move Files to Repo and Move CWD

    !mv YOUR_FILE.CSV YOUR_REPO_PATH
    %cd YOUR_REPO_PATH

Step 5: Add, Commit, and Push Changes

    !git add YOUR_FILE.CSV
    !git commit -m "YOUR_MESSAGE"
    !git push {repo_url}


Use Personal Supabase Key in Google Colab

In the left navigation panel, click on the key icon to input the secret value for your Supabase personal key. Add a new secret, name it 'supabase_key', and paste your key value. Then, grant notebook access to your ExiobaseSupabase Colab.