forked from perlatex/R_for_Data_Science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eda_stars.Rmd
44 lines (33 loc) · 841 Bytes
/
eda_stars.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 地理数据处理 {#eda-stars}
```{r stars-1, message = FALSE, warning = FALSE}
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 stars-2, echo = F, message = F, warning = F, results = "hide"}
pacman::p_unload(pacman::p_loaded(), character.only = TRUE)
```