Skip to content

Instantly share code, notes, and snippets.

Avatar

Grant Williamson ozjimbob

View GitHub Profile
View gdalinfo_txt.
# gdalinfo for a large, integer raster:
Driver: GTiff/GeoTIFF
Files: r_vegmax.tif
Size is 34269, 31580
Coordinate System is:
PROJCS["unknown",
GEOGCS["unknown",
DATUM["Unknown_based_on_GRS80_ellipsoid",
SPHEROID["GRS 1980",6378137,298.2572221010042,
@ozjimbob
ozjimbob / remove_invalid_poly.r
Created Apr 28, 2021
Kill Bad Polygons Dead
View remove_invalid_poly.r
remove_invalid_poly <- function(xx){
to_fix=c()
for(i in 1:nrow(xx)){
mn <- min(sapply(st_geometry(xx)[[i]], function(x) nrow(x[[1]])))
if(mn < 4){
to_fix <- c(to_fix,i)
}
}
for(fix_list in to_fix){
View ProcessList2
library(tidyverse)
library(purrr)
library(readxl)
library(jsonlite)
# Read your spreadsheet
input <- read_excel("Book1-2.xlsx")
# Take your column C and put it into a list, by interpreting the JSON
data <- map(input$context,fromJSON)
View process_list
library(tidyverse)
library(purrr)
# Make a list that looks a bit like yours
# It has two entries
# Each entry has two "normal fields (application, user) - which have different lengths
# And a third field "custom" which contains the weird, staggered dataframe
data <- list()
View gist:b4aa5cb6c873d96adcc30ea9ab2fac85
deb https://qgis.org/ubuntu-ltr focal main
deb-src https://qgis.org/ubuntu-ltr focal main
deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
deb-src https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
View map.r
# If you don't have them installed, install ggmap and ggplot2 packages
install.packages("ggmap")
install.packages("ggplot2")
# Load these packages
library(ggmap)
library(ggplot2)
View unite.r
# Simple tibble
d <- tibble(a1="foo",
a2="bar")
# Want to make a new column called "new" and unite all the "a*" columns together
newcol <- "new"
startchar <- "a"
unite(d,col=newcol,starts_with(startchar)) # Yay
@ozjimbob
ozjimbob / him_anim.r
Created Jan 7, 2020
Example code to generate animation frames of Himawari-8 hotspots
View him_anim.r
# General data manipulation
library(tidyverse)
# Spatial data
library(sf)
# Thematic maps
library(tmap)
View f.r
# ignoring time=t, just modelling on dx for simplicity
frecent3 <- function(rank,dx){
a = 6.1625
cc = 1.6724
b = 0.2882
return(( a/(1e-04 * dx + cc)+b) * rank)
}
View hima_hs.r
library(tidyverse)
library(sf)
library(mapview)
library(furrr)
library(raster)
plan(multiprocess)
ex = extent(c(xmin=-112,xmax=155,ymin=-44,ymax=-10))