Using R, I am trying to obtain an interpolation map in which I am able to see my waypoints and their interpolation (based on their value called N). In the background I wanted to have a black and white map with visible roads and paths. I am sure that it is not complicated to do, but I do not understand where I am making a mistake here.
My data looks like this:
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
Here is my code:
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()
Below is what didn't work. I would like to see my waypoints as points on this interpolation cloud with the highest being darker and the lowest being lighter or white.
I am not able to see my points or my interpolation.