Skip to content

Instantly share code, notes, and snippets.

View Nowosad's full-sized avatar
📭

Jakub Nowosad

📭
View GitHub Profile
# remotes::install_github("mtennekes/tmap")
library(tmap)
library(terra)
#> terra version 1.0.7

# 1 -----------------------------------------------------------------------
elev = rast(system.file("ex/elev.tif", package = "terra"))

tm_shape(elev) +
@Nowosad
Nowosad / st_from_ellipses.R
Created May 29, 2021 14:34
Conversion from a SaTScan text file with ellipses to an sf R spatial object
st_from_ellipses = function(path, crs = "EPSG:25832", res = 30) {
e = read.csv(path)
pnt = sf::st_as_sf(e, coords = c("X", "Y"), crs = crs)
major = pnt$Major
minor = pnt$Minor
angle = pnt$Angle1
rotation = function(a){
r = a * pi / 180 #degrees to radians
matrix(c(cos(r), sin(r), -sin(r), cos(r)), nrow = 2, ncol = 2)
}
library(tmap)
#> Warning: multiple methods tables found for 'area'
data(metro)
metro$group = as.factor(sample(1:5, size = nrow(metro), replace = TRUE))

# two legends
tm_shape(metro) +
  tm_symbols(col = "group", shape = "group")
@Nowosad
Nowosad / check-url.R
Created October 31, 2023 18:11 — forked from nanxstats/check-url.R
A general-purpose link checker for R Markdown and Quarto projects https://nanx.me/blog/post/rmarkdown-quarto-link-checker/
#' Flatten copy
#'
#' @param from Source directory path.
#' @param to Destination directory path.
#'
#' @return Destination directory path.
#'
#' @details
#' Copy all `.Rmd`, `.qmd`, and `.md` files from source to destination,
#' rename the `.qmd` and `.md` files with an additional `.Rmd` extension,