使用 R,我试图获得一个插值图,在其中我能够看到我的航点及其插值(基于它们的值 N)。在背景中,我想要一张带有可见道路和路径的黑白地图。我确信这并不复杂,但我不明白我在哪里犯了错误。
我的数据如下所示:
ALLdata
ID lat long N
1 213 52.36483 20.77724 5
2 214 52.36483 20.77724 5
3 215 52.36483 20.77724 5
4 216 52.20367 20.97026 6
5 217 52.20267 20.96939 7
6 218 52.20371 20.96483 0
7 219 52.20347 20.96595 1
8 220 52.20260 20.96884 2
这是我的代码:
ALLdata <- read.csv("C:/Users/Me/Desktop/sample_animals.csv",header=TRUE,sep=";")
head(ALLdata)
setwd("C:/Users/Me/Desktop/dataFieldseason2016/Graphics") #save graphs and maps
# grab a map. get_map creates a raster object
library(ggmap)
rwanda1 <- get_map(location = c(lon = 20.7, lat = 52.3),
zoom = 9,
maptype = "toner",
source = "stamen")
g1 <- ggmap(rwanda1)
g1
# plot map and animals data
# use coord_map with default mercator projection
g1 +
geom_tile(data = ALLdata, aes(x = long, y = lat, z = N, fill = N), alpha = 0.8) +
stat_contour(data = ALLdata, aes(x = long, y = lat, z = N)) +
ggtitle("animals presence") +
xlab("Longitude") +
ylab("Latitude") +
scale_fill_continuous(name = "animals (N)",
low = "white", high = "blue") +
theme(plot.title = element_text(size = 25, face = "bold"),
legend.title = element_text(size = 15),
axis.text = element_text(size = 15),
axis.title.x = element_text(size = 20, vjust = -0.5),
axis.title.y = element_text(size = 20, vjust = 0.2),
legend.text = element_text(size = 10)) +
coord_map()
下面是什么不起作用。我希望将我的航路点视为此插值云上的点,其中最高点更暗,最低点更亮或白色。
我看不到我的观点或我的插值。