library(tibble)
library(purrr)
t1 <- tibble(`C1 Template` = sample(c(166:180), 10),
`C2 Template` = sample(c(120:130), 10))
t1
#> # A tibble: 10 × 2
#> `C1 Template` `C2 Template`
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
# Description: This script is used to download HLS data from NASA's Earthdata | |
# STAC API and build a cloud-free composite image. | |
# ----- Functions ----- | |
# band mapping for HLS SL data | |
#' @return a named character vector of band mappings for HLS SL data | |
hlssl_band_mapping <- function() { | |
c( | |
B01 = "A", B02 = "B", B03 = "G", B04 = "R", |
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
#' @title Get administritive outlines for a country | |
#' @description using the geoBoundaires API, get the administritive polygon(s) | |
#' for a country | |
#' @param country character vector: a country name | |
#' @param admin_level character vector: the admin level to download | |
#' @param quiet logical, should st_read be quiet? | |
#' @return sf object of the outlines | |
#' @details check out the documentation for the geoboundaries API at: | |
#' geoBoundaries.org | |
#' |
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
#' Buffer a point along a terrain surface. | |
#' | |
#' @param dtm A SpatRaster Digital Terrain Model | |
#' @param pnts A SpatVector of points | |
#' @param .dist Numeric - the buffer distance. | |
#' @param .res Numeric - approximate resampling resolution of the (internally | |
#' calculated) cost raster. | |
#' @param .smooth Logical default FALSE. Should the output buffer be smoothed using `smoothr::smooth`? | |
#' @param .method The smoothing method to use - see `smoothr::smooth` for details. | |
#' @param ... Passed to `smoothr::smooth` for eg. to control smoothness. |
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
#https://twitter.com/AnalyticalEdge/status/1582206425585324034 | |
library(ggplot2) | |
library(stars) | |
library(sf) | |
library(dplyr) | |
library(plotly) | |
.d <- dim(volcano) |
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
#' download drive files from dribble with path column | |
#' | |
#' @param x a dribble with path column | |
#' @param .overwrite logical. Should files be overwritten | |
#' | |
#' @return The original input dribble | |
#' @noRd | |
drive_down_files <- function(x, .overwrite = TRUE) { | |
library(raster)
#> Loading required package: sp
#> Warning: no function found corresponding to methods exports from 'raster' for:
#> 'area'
circ_matrix <- function(n){
if (!n %% 2){
stop("n must be an odd number.")
}
library(vapour)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.3, PROJ 8.2.0; sf_use_s2() is TRUE
#> WARNING: different compile-time and runtime versions for GEOS found:
#> Linked against: 3.10.2-CAPI-1.16.0 compiled against: 3.10.1-CAPI-1.16.0
#> It is probably a good idea to reinstall sf, and maybe rgeos and rgdal too
library(rstac)
mpc_dem <- function(aoi, src = c("cop-dem-glo-30", "alos-dem")) {
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(dplyr) | |
library(mapview) | |
mapviewOptions(fgb = FALSE) | |
plts <- read_sf('data/PlotData/KuamutLocations.shp') | |
pnts <- read_sf("data/Kuamut_2022_NewGPS_Points_Shapefiles/PlotCentre.shp") | |
pnts_clean <- pnts %>% | |
filter(is.na(NUMBER)|NUMBER!=100) %>% | |
mutate(nearest = st_nearest_feature(., plts), |
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
#' Customise style of a targets-derived visNetwork object | |
#' | |
#' @param v object class "visNetwork" from either `tar_visnetwork` or `tar_glimpse` | |
#' @param colors character vector of length 1 or 3. Hex colour codes to define: | |
#' Up to Date, Errored and Outdated targets (in that order). If an object from | |
#' `tar_glimpse` is provided, only the first colour is used to fill the nodes. | |
#' @param shapes a character vector of length 3. any of the following: diamond, | |
#' dot, star, triangle, triangleDown, hexagon, square. | |
#' @param background character - Hex colour codes to define the background | |
#' @param leg_shape_col character - Hex colour code. for tar_visnetwork an |