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
r ggplot2 ggmap r-raster


source to share


No one has answered this question yet

See similar questions:

five
Geographic heatmap custom property in R with ggmap

or similar:

1068
How to concatenate (merge) data frames (inner, outer, left, right)
6
How to change the resolution of a raster layer in R
five
How to invert the colors of a ggmap bitmap in R?
2
R raster data stack over time
2
Overlay raster layer on map in ggplot2 in R?
1
Image of ggmap plot over raster
0
ggmap color according to shooting type
0
How to overlay transparent raster on ggmap?
0
Limited RAM usage with large raster layers in R
0
How to build two rasters with different extensions



All Articles
Loading...
X
Show
Funny
Dev
Pics