Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----setup, eval=FALSE--------------------------------------------------------
# devtools::install_github("EvolEcolGroup/crstools")
## ----get_s_america------------------------------------------------------------
library(rnaturalearth)
library(sf)
s_america_sf <- ne_countries(continent = "South America", returnclass = "sf")
## ----plot_s_america-----------------------------------------------------------
library(ggplot2)
ggplot() +
geom_sf(data = s_america_sf) +
theme_minimal()
## ----check_crs----------------------------------------------------------------
sf::st_crs(s_america_sf)
## ----check_crs_epsg-----------------------------------------------------------
sf::st_crs(s_america_sf)$proj4string
## -----------------------------------------------------------------------------
library(crstools)
s_am_equal_area <- suggest_crs(s_america_sf, distortion = "equal_area")
## -----------------------------------------------------------------------------
s_am_equal_area
## ----plot_s_america_equidist--------------------------------------------------
ggplot() +
geom_sf(data = s_america_sf) +
coord_sf(crs = s_am_equal_area$proj4) +
theme_minimal()
## -----------------------------------------------------------------------------
ggplot(data = s_america_sf) +
geom_sf() +
geom_tissot() +
coord_sf(crs = s_am_equal_area$proj4) +
theme_minimal()
## -----------------------------------------------------------------------------
ggplot(data = s_america_sf) +
geom_sf() +
geom_tissot() +
coord_sf(crs = "+proj=merc") +
theme_minimal()
## -----------------------------------------------------------------------------
s_america_sf_equal_area <- sf::st_transform(s_america_sf, s_am_equal_area$proj4)
sf::st_crs(s_america_sf_equal_area)$proj4string
## ----plot_sa_equidist_proj----------------------------------------------------
ggplot() +
geom_sf(data = s_america_sf_equal_area) +
theme_minimal()
## ----get_raster_europe--------------------------------------------------------
library(terra)
library(pastclim)
# get example dataset from cran
set_data_path(on_CRAN = TRUE)
europe_r <- region_slice(
time_bp = 0,
bio_variables = c("bio01"),
dataset = "Example",
ext = region_extent$Europe
)
## -----------------------------------------------------------------------------
europe_r
## -----------------------------------------------------------------------------
terra::crs(europe_r)
## -----------------------------------------------------------------------------
terra::crs(europe_r, proj = TRUE)
## ----plot_raster_s_america----------------------------------------------------
library(tidyterra)
ggplot() +
geom_spatraster(data = europe_r) +
scale_fill_viridis_c(na.value = "transparent") +
theme_minimal()
## -----------------------------------------------------------------------------
europe_r_equal_area <- suggest_crs(europe_r, distortion = "equal_area")
europe_r_equal_area
## ----plot_raster_europe_ea----------------------------------------------------
ggplot() +
geom_spatraster(data = europe_r) +
scale_fill_viridis_c(na.value = "transparent") +
coord_sf(crs = europe_r_equal_area$proj4) +
theme_minimal()
## -----------------------------------------------------------------------------
ggplot() +
geom_spatraster(data = europe_r) +
scale_fill_viridis_c(na.value = "transparent") +
geom_tissot(data = europe_r) +
coord_sf(crs = europe_r_equal_area$proj4) +
theme_minimal()
## -----------------------------------------------------------------------------
ggplot() +
geom_spatraster(data = europe_r) +
scale_fill_viridis_c(na.value = "transparent") +
geom_tissot(data = europe_r) +
coord_sf(crs = "+proj=merc") +
theme_minimal()
## -----------------------------------------------------------------------------
europe_r_equal_area <- terra::project(europe_r, europe_r_equal_area$proj4)
terra::crs(europe_r_equal_area, proj = TRUE)
## ----plot_raster_europe_ea_proj-----------------------------------------------
ggplot() +
geom_spatraster(data = europe_r_equal_area) +
scale_fill_viridis_c(na.value = "transparent") +
theme_minimal()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.