Skip to content

Instantly share code, notes, and snippets.


Koen Hufkens khufkens

View GitHub Profile
View gist:829e4a5cf063dc9b71b07d0f1f690faf
# convert pngs to mp4
ffmpeg -r 2 -i tmp/%03d.png -y out.mp4
# convert mp4 to twitter compatible format
ffmpeg -i out.mp4 -vf scale=1280:720 -b:v 5000K -minrate 5000K -maxrate 5000K -b:a 128K -r 30 -f mp4 -vcodec libx264 -profile:v high -pix_fmt yuv420p -strict -2 -ac 2 -acodec aac twitter.mp4
khufkens / waffle_plot.R
Last active Jul 20, 2021
Complex waffle plot example
View waffle_plot.R
# data wrangling
# waffle plot
# combining graphs
# text magic
khufkens / downsample_extract_hwsd.R
Last active Jul 7, 2021
Downsample (or extract) HWSD data
View downsample_extract_hwsd.R
# Downsample HWSD data to the scale of 0.5 degree
# WFDEI / CRU data
# get mu_global at 0.5 degrees from the
# ORNL DAAC (which is easier than reading in
# that monstrous BIL file)
khufkens /
Created Jul 1, 2021
Convert equirectangular files to polar projections (upward looking)
# convert equirectangular 2 fisheye
files=`ls *.jpg`
for i in $files;
noext=`echo $i | cut -d'.' -f1`
echo $noext
khufkens / format_phenor_data.R
Created May 28, 2021
Download and format phenocam sites in phenor
View format_phenor_data.R
# required libraries
# where to store the data
out_dir <- "data-raw/"
# sites to process, stored in a csv file
# with columns site, veg_type, roi (check for extra spaces
# which can mess with name formatting)
sites <- read.table("data/sites.csv", sep = ",", header = TRUE)
khufkens /
Created Apr 3, 2021
Animate virtual forest images
# crop section of images
mogrify -crop 2770x2304+3560+296 *.jpg
# compile into animated gif
convert -delay 100 -loop 0 -depth 8 -resize '640x' -quality 75% *.jpg anim.gif
khufkens / MODIS_arctic_sites_download.R
Last active Aug 21, 2020
MODIS arctic sites data request
View MODIS_arctic_sites_download.R
# download NDVI time series
df <- data.frame(
site_name =
khufkens /
Created Nov 19, 2019
Line to run on all images before CV processing
# aligns virtual orientation with physical orientation
mogrify -auto-orient *.png
khufkens /
Last active Jun 19, 2020
Montage of example numbers for zooniverse project
montage *.png -bordercolor White -border 5x5 -colorspace Gray -gravity center -tile 7x -geometry +10+0 ~/montage.jpg
khufkens / ghent_air_quality_vmm.R
Created Jun 12, 2019
Ghent air quality study VMM rehash
View ghent_air_quality_vmm.R
# Ghent air pollution analysis
# parametric t-tests
# non-parametric Mann-Whitney U test
# download and collate the data
pdf_data <- paste0(pdftools::pdf_text("")[2],
collapse = " ")
# some regular expression moving about
subset <- gsub(',', ".", pdf_data)