Recently Published
TAREA6DEF
Dashboard quarto
Plot library tydiverse
library(tidyverse) |> suppressPackageStartupMessages()
nc.32119 <- st_transform(nc, 32119)
year_labels <-
c("SID74" = "1974 - 1978", "SID79" = "1979 - 1984")
nc.32119 |> select(SID74, SID79) |>
pivot_longer(starts_with("SID")) -> nc_longer
ggplot() + geom_sf(data = nc_longer, aes(fill = value), linewidth = 0.4) +
facet_wrap(~ name, ncol = 1,
labeller = labeller(name = year_labels)) +
scale_y_continuous(breaks = 34:36) +
scale_fill_gradientn(colours = sf.colors(20)) +
theme(panel.grid.major = element_line(colour = "white"))
Plot library(stars)
library(stars)
# Loading required package: abind
system.file("tif/L7_ETMs.tif", package = "stars") |>
read_stars() -> r
st_bbox(r) |> st_as_sfc() |> st_sample(5) |>
st_buffer(300) -> circ
hook <- function() {
plot(circ, col = NA, border = 'yellow', add = TRUE)
}
plot(r, hook = hook, key.pos = 4)
Plotlibrary(sf)
library(sf)
nc <- read_sf(system.file("gpkg/nc.gpkg", package = "sf"))
plot(nc["BIR74"], reset = FALSE, key.pos = 4)
plot(st_buffer(nc[1,1], units::set_units(10, km)), col = 'NA',
border = 'red', lwd = 2, add = TRUE)
TAREA6DEF
homework
Plot install.packages("rnaturalearthdata") library(rnaturalearth)
install.packages("rnaturalearthdata")
library(rnaturalearth)
w <- ne_countries(scale = "medium", returnclass = "sf")
suppressWarnings(st_crs(w) <- st_crs('OGC:CRS84'))
layout(matrix(1:2, 1, 2), c(2,1))
par(mar = rep(0, 4))
plot(st_geometry(w))
# sphere:
old <- options(s2_oriented = TRUE) # don't change orientation from here on
countries <- s2::s2_data_countries() |> st_as_sfc()
globe <- st_as_sfc("POLYGON FULL", crs = st_crs(countries))
oceans <- st_difference(globe, st_union(countries))
visible <- st_buffer(st_as_sfc("POINT(-30 -10)", crs = st_crs(countries)), 9800000) # visible half
visible_ocean <- st_intersection(visible, oceans)
visible_countries <- st_intersection(visible, countries)
st_transform(visible_ocean, "+proj=ortho +lat_0=-10 +lon_0=-30") |>
plot(col = 'lightblue')
st_transform(visible_countries, "+proj=ortho +lat_0=-10 +lon_0=-30") |>
plot(col = NA, add = TRUE)