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
library(sp) | |
library(rgdal) | |
exts <- c(".shp", ".dbf", ".sbn", ".sbx", ".shx") | |
dt_path <- paste0(tempfile(), exts) | |
dt <- download.file(paste0("http://geog.uoregon.edu/GeogR/data/shp/orstations", | |
exts), dt_path) | |
dt <- readOGR(dt_path[1]) |
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
# See http://www.johnmyleswhite.com/notebook/2010/08/20/using-jags-in-r-with-the-rjags-package/ | |
N <- 1000 | |
x <- rnorm(N, 0, 5) | |
modelstring <- " | |
model { | |
for(i in 1:N) { | |
x[i] ~ dnorm(mu, tau) | |
} |
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
# National Landcover Database 2006 (NLCD) | |
nlcd_palette <- data.frame( | |
class = c("water", "water", | |
"developed", "developed", "developed", "developed", | |
"barren", | |
"forest", "forest", "forest", | |
"shrubland", "shrubland", | |
"herbaceous", "herbaceous", "herbaceous", "herbaceous", | |
"planted", "planted", |
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
x <- seq(0, 10, length.out = 80) | |
y <- x | |
#' @param slope numeric slope of the original line | |
#' @param frac_along numeric fraction along the original line to draw control point array | |
#' @param seq_len numeric fraction of the line to include as a control point | |
#' | |
generate_perp <- function(x, y, slope = 1, frac_along = 0.5, seq_len = c(0.25)){ | |
lapply(frac_along, function(i) { | |
x_offset <- i * range(x)[2] - 5 |
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
library(sf) | |
library(ggplot2) | |
# crs <- st_crs(orig_sf) | |
# test <- st_geometry(orig_sf) | |
# test_text <- st_as_text(test) | |
crs <- st_crs(32610) | |
test_text <- "LINESTRING(4683684.86627714 6127410.96399602, 4683791.86302937 6127277.7501861, 4683823.72428078 6127263.81933025, 4683937.27439384 6127249.11683816, 4683969.89585432 6127219.69092887, 4683951.89224796 6127168.37796377, 4683866.89142587 6127085.63923137, 4683850.50012205 6127051.83321428, 4683847.90414026 6126904.28325476, 4683913.46734349 6126776.99477916, 4683939.65765144 6126701.82749159, 4683999.27975858 6126605.97125794, 4684069.7019509 6126531.19991619, 4684137.39774915 6126498.57646262, 4684185.17287752 6126465.56639239)" |
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
dt <- data.frame(a = seq(1, 10) + rnorm(1)) | |
# option 1 #### | |
key_function <- function(x) { | |
if(x > 7){ | |
"x" | |
}else{ | |
if(x > 4 & x < 7){ | |
"y" | |
}else{ |
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
library(glmtools) | |
estimate_linear <- function(nlayers, surface_area, max_depth){ | |
layer_thickness <- max_depth / nlayers | |
depth_vec <- seq(0, max_depth, by = layer_thickness) | |
df_pred <- data.frame( | |
areas = c(surface_area, 0), | |
layer_ind = c(1, nlayers + 1)) | |
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
x <- 1:10 | |
y <- 1 - (1 / (1 + 2*x)) | |
yeps <- y + rnorm(length(y), sd = 0.01) # added noise | |
fit <- nls(yeps ~ 1 - (1 / (1 + b*x)), start = list(b = 2)) | |
coef(fit) | |
plot(x, y) | |
lines(x, predict(fit)) |
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
ogr2ogr -f GPKG foo.gpkg foo.gdb |
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
library(sbtools) | |
library(readxl) | |
library(dams) | |
library(dplyr) | |
library(sf) | |
library(maps) | |
library(ggplot2) | |
# Get Reservoir Morphology Database #### | |
temp_dir <- tempdir() |