94

时空数据

stars 时空栅格

应用篇
R
library(tidyverse)
library(sf)
library(stars)

library("rnaturalearth")
library("rnaturalearthdata")

获取世界地图数据

R
world_map_data <- ne_countries(scale = "medium", returnclass = "sf")

ggplot(data = world_map_data) +
    geom_sf()

使用不同的坐标系统

R
ggplot(data = world_map_data) +
    geom_sf() +
    coord_sf(crs = st_crs(3035))

上色

R
ggplot(data = world_map_data) + 
    geom_sf(color = "black", fill = "lightgreen")
R
ggplot(data = world_map_data) +
    geom_sf(aes(fill = pop_est)) +
    scale_fill_viridis_c(option = "plasma", trans = "sqrt")
R
pacman::p_unload(pacman::p_loaded(), character.only = TRUE)