[英]How to invert the colors of a ggmap raster image in R?
這將反轉由get_stamenmap()
返回的raster
對象
library("ggmap")
m <- get_stamenmap(maptype = "toner")
# invert colors in raster
invert <- function(x) rgb(t(255-col2rgb(x))/255)
m_inv <- as.raster(apply(m, 2, invert))
# copy attributes from original object
class(m_inv) <- class(m)
attr(m_inv, "bb") <- attr(m, "bb")
ggmap(m_inv)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.