简单的plotRGB导致original image,而使用tmap进行绘制则返回only a blue-shaded image。我在做什么错了?
代码段:
library(raster)
library(tmap)
library(rnaturalearth)
ne_download(scale = 50, type = 'HYP_50M_SR_W', category = 'raster', destdir = getwd())
rst <- brick("HYP_50M_SR_W/HYP_50M_SR_W.tif")
plotRGB(rst) # works
tmap_mode("plot")
tm_shape(rst) + tm_rgb() # does not work
使用:R版本3.5.1,RStudio 1.1.456,tmap 2.1-1,栅格2.6-7,rnaturalearth 0.1.0
答案 0 :(得分:1)
它现在可能正在运行,但是请注意警告:
library(raster)
#> Loading required package: sp
library(tmap)
#> Warning: package 'tmap' was built under R version 3.5.2
library(rnaturalearth)
#> Warning: package 'rnaturalearth' was built under R version 3.5.2
ne_download(scale = 50, type = 'HYP_50M_SR_W', category = 'raster', destdir = getwd())
rst <- brick("HYP_50M_SR_W/HYP_50M_SR_W.tif")
plotRGB(rst)
tm_shape(rst) + tm_rgb()
#> Raster object has 58320000 (5400 by 10800) cells, which is larger than 1e+07, the maximum size determined by the option max.raster. Therefore, the raster will be shown at a decreased resolution of 1e+07 cells. Set tmap_options(max.raster = c(plot = 58320000, view = 58320000)) to show the whole raster.
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
由reprex package(v0.2.1)于2019-01-30创建
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> os Windows 7 x64 SP 1
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz Europe/Berlin
#> date 2019-01-30
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.5.1)
#> backports 1.1.2 2017-12-13 [1] CRAN (R 3.5.0)
#> base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.5.0)
#> callr 3.0.0 2018-08-24 [1] CRAN (R 3.5.1)
#> class 7.3-14 2015-08-30 [2] CRAN (R 3.5.1)
#> classInt 0.2-3 2018-04-16 [1] CRAN (R 3.5.1)
#> cli 1.0.1 2018-09-25 [1] CRAN (R 3.5.1)
#> codetools 0.2-15 2016-10-05 [2] CRAN (R 3.5.1)
#> colorspace 1.3-2 2016-12-14 [1] CRAN (R 3.5.1)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
#> crosstalk 1.0.0 2016-12-21 [1] CRAN (R 3.5.1)
#> curl 3.2 2018-03-28 [1] CRAN (R 3.5.1)
#> DBI 1.0.0 2018-05-02 [1] CRAN (R 3.5.1)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.1)
#> devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.1)
#> dichromat 2.0-0 2013-01-24 [1] CRAN (R 3.5.0)
#> digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.1)
#> e1071 1.7-0 2018-07-28 [1] CRAN (R 3.5.1)
#> evaluate 0.12 2018-10-09 [1] CRAN (R 3.5.1)
#> fs 1.2.6 2018-08-23 [1] CRAN (R 3.5.1)
#> glue 1.3.0 2018-07-17 [1] CRAN (R 3.5.1)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.1)
#> htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.5.1)
#> httpuv 1.4.5 2018-07-19 [1] CRAN (R 3.5.1)
#> httr 1.3.1 2017-08-20 [1] CRAN (R 3.5.1)
#> KernSmooth 2.23-15 2015-06-29 [2] CRAN (R 3.5.1)
#> knitr 1.20 2018-02-20 [1] CRAN (R 3.5.1)
#> later 0.7.5 2018-09-18 [1] CRAN (R 3.5.1)
#> lattice 0.20-35 2017-03-25 [2] CRAN (R 3.5.1)
#> leaflet 2.0.2 2018-08-27 [1] CRAN (R 3.5.1)
#> lwgeom 0.1-5 2018-12-07 [1] CRAN (R 3.5.1)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
#> mapview 2.6.0 2018-09-16 [1] CRAN (R 3.5.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.1)
#> mime 0.6 2018-10-05 [1] CRAN (R 3.5.1)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.1)
#> pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.1)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.1)
#> png 0.1-7 2013-12-03 [1] CRAN (R 3.5.0)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1)
#> processx 3.2.0 2018-08-16 [1] CRAN (R 3.5.1)
#> promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.1)
#> ps 1.2.1 2018-11-06 [1] CRAN (R 3.5.1)
#> R6 2.3.0 2018-10-04 [1] CRAN (R 3.5.1)
#> raster * 2.8-4 2018-11-03 [1] CRAN (R 3.5.1)
#> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.5.0)
#> Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.5.1)
#> remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.1)
#> rgdal 1.3-6 2018-10-16 [1] CRAN (R 3.5.1)
#> rgeos 0.4-2 2018-11-08 [1] CRAN (R 3.5.1)
#> rlang 0.3.0.1 2018-10-25 [1] CRAN (R 3.5.1)
#> rmarkdown 1.10 2018-06-11 [1] CRAN (R 3.5.1)
#> rnaturalearth * 0.1.0 2017-03-21 [1] CRAN (R 3.5.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
#> satellite 1.0.1 2017-10-18 [1] CRAN (R 3.5.1)
#> scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.1)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.1)
#> sf * 0.7-1 2018-10-24 [1] CRAN (R 3.5.1)
#> shiny 1.2.0 2018-11-02 [1] CRAN (R 3.5.1)
#> sp * 1.3-1 2018-06-05 [1] CRAN (R 3.5.1)
#> spData 0.2.9.4 2018-09-15 [1] CRAN (R 3.5.1)
#> stringi 1.2.4 2018-07-20 [1] CRAN (R 3.5.1)
#> stringr 1.3.1 2018-05-10 [1] CRAN (R 3.5.1)
#> tmap * 2.2 2019-01-05 [1] CRAN (R 3.5.2)
#> tmaptools 2.0-1 2018-08-07 [1] CRAN (R 3.5.1)
#> units 0.6-1 2018-09-21 [1] CRAN (R 3.5.1)
#> usethis 1.4.0 2018-08-14 [1] CRAN (R 3.5.1)
#> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.1)
#> webshot 0.5.1 2018-09-28 [1] CRAN (R 3.5.1)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)
#> XML 3.98-1.16 2018-08-19 [1] CRAN (R 3.5.1)
#> xml2 1.2.0 2018-01-24 [1] CRAN (R 3.5.1)
#> xtable 1.8-3 2018-08-29 [1] CRAN (R 3.5.1)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.1)