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")
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
#' 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, |
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
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) | |
} |
# 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) +
- blog post "Persistent config and data for R packages" - https://blog.r-hub.io/2020/03/12/user-preferences/#not-so-temporary-files3 - https://twitter.com/ma_salmon/status/1295031507648753664
- ceramic - https://github.com/hypertidy/ceramic - https://twitter.com/mdsumner/status/1295185950385950721
- sen2r - https://github.com/ranghetti/sen2r - https://twitter.com/JamesPDuffy/status/1295114112855412737
- tidycensus - https://github.com/walkerke/tidycensus - https://twitter.com/StatSteph/status/1295305125049905154
- datastorr - https://github.com/ropenscilabs/datastorr - https://twitter.com/noamross/status/1295450860118515713
- portalr - https://github.com/weecology/portalr/ - https://twitter.com/Hao_and_Y/status/1295033319386562561
- rdataretriever - https://github.com/ropensci/rdataretriever - https://twitter.com/henrykironde/status/1295084398421966849
- rgbif - https://github.com/ropensci/rgbif - https://twitter.com/BrentPease1/status/1295062968808476672
- bowerbird - https://github.com/ropensci/bowerbird -
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(spData) | |
str(nz) | |
# change class for one column | |
nz2 = nz %>% | |
mutate(Land_area = as.factor(Land_area)) |
library(gganimate)
#> Loading required package: ggplot2
library(ggplot2)
ggplot(diamonds, aes(cut, carat)) +
geom_point(col = "red") +
geom_boxplot() +
transition_layers(layer_length = 1, transition_length = 1)
#> Error in `$<-.data.frame`(`*tmp*`, ".phase", value = "raw"): replacement has 1 row, data has 0
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
#' Shannon's Evenness Index | |
#' | |
#' @description Evenness of patch types (classes) in the landscape | |
#' | |
#' @param landscape Raster* Layer, Stack, Brick or a list of rasterLayers. | |
#' @return tibble | |
#' | |
#' @examples | |
#' lsm_l_shei(landscape) | |
#' lsm_l_shei(landscape_stack) |
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.4, proj.4 4.9.3
library(spData)
library(tmap)
tm_shape(nz) +
tm_polygons() +
tm_compass(position = c("left", "top")) +
tm_scale_bar()
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(sf) | |
library(tidyverse) | |
g = SpatialGrid(GridTopology(c(0, 0), c(1, 1), c(3, 3))) | |
p = as(g, "SpatialPolygons") %>% | |
st_as_sf() %>% | |
mutate(id = row_number()) %>% | |
as("Spatial") |
NewerOlder