Skip to content

Instantly share code, notes, and snippets.

View geponce's full-sized avatar

Guillermo E. Ponce-Campos geponce

View GitHub Profile
@geponce
geponce / zonalStats.py
Last active May 18, 2016 22:33
Zonal statistics from geotif files...
# Extract an aggregation of pixels from geotifs using a multi-polygon shapefile
# Output:
# A csv file with one-row per polygon and as many columns as the number
# geotif files processed
# @USDA-ARS-Tucson, AZ
# @Date: 04/02/2016
import os
import json
import pandas as pd
from rasterstats import zonal_stats, point_query
@geponce
geponce / SPEI_from_IPCC_data.R
Last active October 16, 2025 08:23
Script to compute SPEI drought index using PET and Precipitation from IPCC
GetSPEI_Rasters_from_IPCC <- function(path, dateStart, dateEnd) {
# Generate monthly SPEI rasters using IPCC PETnatveg and Precipitation
# Args:
# path: A string value with the directory where the .nc files are located
# dateStart: A string value with the starting date in the format: 2014-01-01
# dateEnd: A string value with the ending date, same format
# Returns:
# SPEI Raster files as geotif for each model
# @USDA-ARS-Tucson, AZ
# @Date: 05/16/2016
@geponce
geponce / IPCC_netcdf2tif.R
Last active May 17, 2016 17:57
Script to convert IPCC netcdf monthly time series into geotif files for the CONUS extent
ConvertIPCC_netcdf2geoTiff <- function (path, dateStart, dateEnd) {
# Converts IPCC netcdf time series into geotif files for the CONUS extent
# Args:
# path: A string value with the directory where the .nc files are located
# dateStart: A string value with the starting date in the format: 2014-01-01
# dateEnd: A string value with the ending date, same format
# Returns:
# Raster files as geotif for each month/model
# @USDA-ARS-Tucson, AZ
# @Date: 05/10/2016