更新时间:2023-02-14 12:51:39
以下是一种方法:
获取大量数据:
library(marmap)
Bathy <- getNOAA.bathy(lon1 = 37, lon2 = 38.7,
lat1 = -45.5, lat2 = -47.3, resolution = 1)
将其转换为矩阵:
Bathy <- as.matrix(Bathy)
class(Bathy) <- "matrix"
现在将其重塑为长格式并绘图
now reshape it to long format and plot
library(tidyverse)
Bathy %>%
as.data.frame() %>%
rownames_to_column(var = "lon") %>%
gather(lat, value, -1) %>%
mutate_all(funs(as.numeric)) %>%
ggplot()+
geom_contour(aes(x = lon, y = lat, z = value), bins = 10, colour = "black") +
coord_map()