How to change color of raster data when merging raster layer and ggmap
I am currently researching something on a raster layer and I can set the raster layer to ggmap using inset_raster (). Here's some sample code below:
library(ggmap)
library(animation)
auckland <- get_map(location = "Auckland",
zoom = 14,
scale = 2, ## 1280*1280 pixels
maptype = "roadmap",
color = "color")
auckland_vis <- ggmap(ggmap = auckland)
auckland_vis
rainbow <- matrix(seq(360, 2000, length = 50 * 50), nrow = 50)
rainbow[sample(1:length(rainbow), 2400, replace = FALSE)] <- NA
rainbow.r <- raster(rainbow)
## inset_raster is used to put a raster layer on a ggmap
auckland_vis +
inset_raster(rainbow.r, xmin = attributes(auckland)$bb$ll.lon,
xmax = attributes(auckland)$bb$ur.lon,
ymin = attributes(auckland)$bb$ll.lat,
ymax = attributes(auckland)$bb$ur.lat
)
Please ignore if the points on the map are reasonable or not. I know how to change the color of the raster data when using plot()
. I would also like to know how to change the color of points in ggmap. For now, the colors are always white, pink, yellow, and green (what if I want the colors to be blue-yellow and red). Is there a function that can specify color just like in ggplot?
Thank you in advance
+3
source to share
No one has answered this question yet
See similar questions:
or similar: