Skip to content

SkyTruth/tpae

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terrestrial Protected Area Effectiveness

This repository contains preliminary code related to the development of a Terrestrial Protected Area Effectiveness (TPAE) model. TPAE is part of SkyTruth's 30x30 progress tracking initiative.

Repository Contents

  • src/absolute_effectiveness/: Class-based analysis components for evaluating absolute effectiveness.
    • SiteSelector: Retrieves selected test sites and derives site-specific variables.
    • DataProcessor: Loads and processes Earth Engine datasets (GLC, GPW, NFW, HGFC) for the selected sites and analysis period.
    • HabitatConditionAnalyzer: Calculates habitat extent, intactness, and overall habitat condition score.
    • HabitatLossAnalyzer: Calculates habitat loss score and summarizes the drivers and types of habitat loss.
    • VisualizationService: Builds cloud-masked Sentinel-2 composites to aid map visualization.
  • notebooks/run_absolute_effectiveness.ipynb: Notebook for testing absolute effectiveness code individually on various test sites and visualizing results.
  • src/utils/variables.py: Constants related to absolute effectiveness code. s

Working in this Repository

  • This repository uses ruff pre-commit hooks.
  • This repository uses Poetry for package and dependency management (see below for installation and set-up).

Poetry Installation and Set-up

Note: Python needs to be installed before poetry.

Mac / Linux

  1. Install Poetry
  2. After installing poetry, add the Poetry bin to PATH by adding the following line to .zshrc:
export PATH="$HOME/.local/bin:$PATH"

Windows

  1. Open PowerShell in Administrator mode (windows menu > Powershell > right click > Administrator)
  2. Install Poetry:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
  • It is probably possible (and better) to add the PATH to the Poetry app to your environment somehow, but we could not figure out how to make that work so instead we set up an Alias so that we could run poetry commands
  1. Set execution policy (this makes your computer slightly less secure, but if you aren't downloading potential malware via Powershell, you're alright)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
  1. create user profile: open $PROFILE in notepad:
notepad $PROFILE
  1. Add the following to that file (replace YourUsername with the correct identifier):
Set-Alias poetry "C:\Users\<YourUsername>\AppData\Roaming\Python\Scripts\poetry.exe"

Using Poetry

Working in the poetry environment

This repo already has a pyproject.toml and a poetry.lock file. These define the virtual environment (sort of like how requirements.txt defines a pip environment, but these files resolve dependencies and ensure everyone has the same dependencies, since those are defined in the lockfile).

To work in the poetry virtual environment, you just need to prepend all command line statements with poetry run (i.e. instead of python hello_world.py you would simply run poetry run python hello_world.py)

Alternatively, you can work work entirely in the environment (similar to conda activate) with the command poetry shell, and then you can just run python hello_world.py

Install environment

Do this each time you pull the repo in case there have been changes to the dependencies:

poetry install

Updating the environment

Adding a new library:

poetry add <new-package>

Deleting a library

poetry remove <old-package>

License

This work is licensed under the Apache License, Version 2.0. See LICENSE.txt

About

Terrestrial Protected Area Effectiveness

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors