Skip to content

Instantly share code, notes, and snippets.

View richpsharp's full-sized avatar

Richard Sharp richpsharp

View GitHub Profile
@richpsharp
richpsharp / sipa_to_table_legend.py
Created September 4, 2024 18:51
SIPA to table for Shail on 2024 09 04
import pandas as pd
datasets={
"PH_Top 10% of service overlap for _PH conservation": {
'fig_title' :"Top 10% of service overlap for , PH conservation",
'country' :"PH",
'labels' :["1 service","2 services","3 services","4 services"],
'visParams':{
'min':1,
'max':4,
@richpsharp
richpsharp / process_dannys_file_to_pcld_format.py
Created June 11, 2025 23:14
Convert Danny's R table to a CSV and reproject and rename
"""Script to process Danny's RDS file into something that can be analyzed by the PCLD."""
import pyreadr
import geopandas as gpd
PROJECTION_EPSG = 32610
FILE_PATH = "Karp_LU_UseCase.RDS"
def main():
@richpsharp
richpsharp / gpw_fragmentation.json
Last active July 7, 2025 20:16
"Fragmentation Index" using global pasture watch
var grassland_fragmentation = function(aoi, year)
{
var global_pasture_watch = ee.ImageCollection('projects/global-pasture-watch/assets/ggc-30m/v1/grassland_c');
var clipped_gpw = global_pasture_watch.filterDate(year + '-01-01', (year + 1) + '-01-01').first().clip(aoi);
// Anything > 1 is grassland "i.e. rangeland"
var grassland = clipped_gpw.gte(1);
//original code made a 7x7 square kernel on 10m, so we're doing a 3x3 for 30m as close enough