This file contains 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
# values specific to your stac source | |
# in this case, from | |
# https://planetarycomputer.microsoft.com/dataset/usgs-lcmap-conus-v13 | |
COLLECTION="usgs-lcmap-conus-v13" | |
ASSET="lcpri" | |
# query parameters: bbox (wgs84) and datetime (utc) | |
# I grabbed these values from R | |
WGS84_BBOX="-79.762,40.496,-71.856,45.013" | |
DATETIME="2021-01-01/2021-12-31" |
This file contains 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
stack_rasters <- function(rasters, | |
raster_path, | |
..., | |
reference_layer = 1, | |
resampling_method = "bilinear") { | |
check_type_and_length( | |
reference_layer = integer(1) | |
) |
This file contains 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
FROM tuxmake/clang-15 | |
RUN apt-get update -y ; apt-get install -y curl | |
RUN curl -Ls https://github.com/r-lib/rig/releases/download/latest/rig-linux-latest.tar.gz | tar xz -C /usr/local | |
RUN rig add devel | |
RUN mkdir ~/.R |
This file contains 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(spatialsample) | |
# Might need to get the CRS if you haven't before: | |
sf::sf_proj_network(TRUE) | |
sf::sf_add_proj_units() | |
spatial_clustering_cv(boston_canopy, v = 5) |> | |
autoplot() | |
spatial_block_cv(boston_canopy, v = 5, method = "snake") |> |
This file contains 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
# remotes::install_github('tidymodels/spatialsample') | |
library(spatialsample) | |
library(cluster) | |
make_clusters <- function(func) { | |
set.seed(123) | |
boston_canopy |> | |
spatial_clustering_cv(cluster_function = func) |> | |
autoplot() | |
} |
This file contains 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
# 12.5 Spatial CV (with spatialsample) | |
library(tidymodels) | |
library(spatialsample) | |
library(sf) | |
data("lsl", "study_mask", package = "spDataLarge") | |
lsl <- lsl |> | |
st_as_sf(coords = c("x", "y"), crs = "EPSG:32717") | |
ta <- terra::rast(system.file("raster/ta.tif", package = "spDataLarge")) |
This file contains 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
.cursor <- R6::R6Class( | |
"cursor", | |
list( | |
x = 0, | |
y = 0, | |
direction = 0, | |
left = function() { | |
self$direction <- self$direction + 270 | |
invisible(self) | |
}, |
This file contains 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(tidycensus) | |
library(dplyr) | |
library(ggplot2) | |
options(tigris_use_cache = TRUE) | |
acs_pop <- do.call( | |
rbind, | |
lapply( | |
setdiff(state.abb, c("AK", "HI")), |
This file contains 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(terrainr) | |
library(raster) | |
library(rayshader) | |
library(sf) | |
baker <- tmaptools::geocode_OSM("Mount Baker") | |
baker <- st_as_sf(as.data.frame(t(as.data.frame(baker$coords))), coords = c("x", "y"), crs = 4326) | |
zscale <- 5 | |
baker <- set_bbox_side_length( | |
baker, |
This file contains 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(tidycensus) | |
library(ggplot2) | |
library(dplyr) | |
acs_pop <- lapply( | |
setdiff(state.abb, c("AK", "HI")), | |
\(x) { | |
get_acs( | |
geography = "block group", |
NewerOlder