```R
#install.packages("ggplot2")
#install.packages("sf")
#install.packages("ggimage")
library(ggplot2)
library(sf)
library(ggspatial)
library(ggimage)
# 示例数据www
SampleID = c("Point 1", "Point 2", "Point 3", "Point 4", "Point 5"),
Longitude = c(-120.5, -120.4, -120.3, -120.2, -120.1),
Latitude = c(35.5, 35.6, 35.7, 35.8, 35.9),
Direction = c("north", "east", "south", "west", "north")
)
# 将数据框转换为地理空间对象
sample_points <- st_as_sf(sample_points, coords = c("Longitude", "Latitude"))
# 设置坐标参考系统
st_crs(sample_points) <- st_crs("+proj=longlat +datum=WGS84")
# 创建地图底图
base_map <- ggplot() +
annotation_map_tile(zoom = 10, type = "osm") +
coord_sf(xlim = c(-121, -120), ylim = c(33, 36), expand = FALSE)
line_layer <- base_map +
geom_sf(data = sample_points,
aes(color = SampleID, size = 3)) +
geom_sf_text(data = sample_points,
aes(label = SampleID), color = "black", size = 3, nudge_y = 0.001) +
geom_sf(data = st_cast(st_union(sample_points), "LINESTRING"),
color = "red", size = 1)
# 绘制野外调查线路图
line_layer
```