This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal enabledelayedexpansion | |
| rem usage: script.bat 2000 2007 | |
| set START_YEAR=%1 | |
| set END_YEAR=%2 | |
| for /L %%Y in (%START_YEAR%,1,%END_YEAR%) do ( | |
| if not exist "%%Y" mkdir "%%Y" | |
| echo Copying year %%Y... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| import json | |
| import ee | |
| BAD_STATES = {"FAILED", "CANCELLED", "CANCEL_REQUESTED"} | |
| def init_ee(): | |
| """Initalize earthengine api with authentication.""" | |
| key_file = "/workdir/secrets/service-account-key.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| repeating_dec_12ths = ['0833', '1666', '3333', '4166', '5833', '6666', '8333', '9166'] | |
| # 0.0833 - 1/12 | |
| # 0.1666 - 1/6 | |
| # 0.3333 - 1/3 | |
| # 0.4166 - 5/12 | |
| # 0.5833 - 7/12 | |
| # 0.6666 - 2/3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run as: | |
| # docker run --rm -it -v %CD%:/usr/local/workspace --volume=%CD%/gurobi.lic:/opt/gurobi/gurobi.lic:ro --volume=%CD%/models:/models:ro prioritizr ./run-prioritizations.R | |
| FROM gurobi/optimizer | |
| RUN apt-get update -qq | |
| RUN apt-get install -y libgdal-dev | |
| RUN apt-get install -y r-base r-base-dev | |
| RUN apt-get install -y libudunits2-dev | |
| RUN apt-get install -y libssl-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Convert isimib2 to geotiff.""" | |
| import os | |
| import glob | |
| import xarray as xr | |
| from osgeo import gdal | |
| from osgeo import osr | |
| LOCAL_RASTER_CREATION_OPTIONS = ( | |
| 'TILED=YES', 'BIGTIFF=YES', 'COMPRESS=LZW', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy | |
| import scipy.optimize | |
| evi_vs_c = [ | |
| (0.02874, 0.95), | |
| (0.18186, 0.25), | |
| (0.3643000126, 0.13575), | |
| (0.33039, 0.07075), | |
| (0.54826, 0.035425), | |
| (0.65346, 0.0001), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vector = gdal.OpenEx(vector_path, gdal.OF_VECTOR) | |
| layer = vector.GetLayer() | |
| layer.SetAttributeFilter('Country="USA"') # or whatever... | |
| feature = layer.GetNextFeature() | |
| geom = feature.GetGeometryRef() | |
| envelope = geom.GetEnvelope() | |
| target_bb = [envelope[i] for i in [0, 2, 1, 3]]) | |
| geom = None | |
| feature = None |
NewerOlder