Skip to content

Instantly share code, notes, and snippets.

View PMassicotte's full-sized avatar
🌟
Working from home

Philippe Massicotte PMassicotte

🌟
Working from home
View GitHub Profile
library(graticule)
lons <- seq(-80, -40, by = 5)
lats <- seq(77, 84.5, by = .5)
latpts <- cbind(min(lons), lats)
lonpts <- cbind(lons, min(lats))

prj <- "+proj=laea +lat_0=90 +lon_0=-60"
xy_lon <- sf::sf_project(pts = lonpts, to = prj, from = "OGC:CRS84")
xy_lat &lt;- sf::sf_project(pts = latpts, to = prj, from = "OGC:CRS84")
library(terra)
#> terra 1.5.34
r <- rast("/vsicurl/https://dapds00.nci.org.au/thredds/fileServer/gb6/BRAN/BRAN2020/daily/ocean_u_2010_01.nc", lyrs = 1:10)
crs(r) <- "EPSG:4326"

e <- ext(c(xmin = 104, xmax = 138, ymin = 13, ymax = 32))

## set up a lower resolution
target_rast &lt;- crop(rast(r), e)
@shannonpileggi
shannonpileggi / demo_walrus
Created February 13, 2021 05:20
A demonstration of the walrus operator
library(tidyverse)
library(rlang)
library(glue)
# string to append to variable name
suffix <- "A"
# example data frame
dat <- tibble(x = 1:5) %>%
# create new variable with walrus operator
@keeferrourke
keeferrourke / install-google-fonts.sh
Last active May 22, 2023 12:38
A bash script to install all Google Fonts, system wide, on debian based systems (ex. Ubuntu)
#!/bin/sh
# Written by: Keefer Rourke <https://krourke.org>
# Based on AUR package <https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-google-fonts-git>
# dependancies: fonts-cantarell, ttf-ubuntu-font-family, git
sudo apt-get install fonts-cantarell ttf-ubuntu-font-family git
srcdir="/tmp/google-fonts"
pkgdir="/usr/share/fonts/truetype/google-fonts"
giturl="git://github.com/google/fonts.git"