r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
868 stars 121 forks source link

Errors when plotting rgb data like Landsat images with 0-1 scale range and several bands #294

Closed CamiloEr closed 2 years ago

CamiloEr commented 5 years ago

I'am preprocessing a Landsat7 Surface Reflectance image: I loaded all bands with raster::stack, applied a factor scale to each band (1e-04) and removed values out the 0-1 range (saturated ones).

I want to plot this image with tmap::tm_rgb but it shows me some errors (with raster::plotRGB it works). The first one is because the RasterBrick has more than 3 bands, I suppose? And the second one is because the range values of each band are 0-1 and not 0-255?.

Here is a (partially) reproducible example:

library(raster)
#> Loading required package: sp
library(tmap)
#> Warning: package 'tmap' was built under R version 3.5.3

L7_09_2013_01_13 <-  brick("C:/raster_temporal/clean.grd") #Partially because of this 
L7_09_2013_01_13
#> class       : RasterBrick 
#> dimensions  : 2456, 3282, 8060592, 6  (nrow, ncol, ncell, nlayers)
#> resolution  : 30, 30  (x, y)
#> extent      : 384375, 482835, 948315, 1021995  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : C:/raster_temporal/clean.grd 
#> names       : layer.1, layer.2, layer.3, layer.4, layer.5, layer.6 
#> min values  :  0.0185,  0.0175,  0.0099,  0.0119,  0.0001,  0.0013 
#> max values  :  0.6185,  0.6992,  0.6715,  0.9994,  0.9554,  0.9983

plotRGB(L7_09_2013_01_13, r=3, g=2, b=1, stretch="hist")


tm_shape(L7_09_2013_01_13)+ #Error because it has 6 bands, I suppose?
  tm_rgb() 
#> Error: Raster object does not have a color table, nor numeric data that can be converted to colors. Use tm_raster to visualize the data.

tm_shape(L7_09_2013_01_13[[1:3]])+
  tm_rgb() #Error because its range is 0-1 and not 0-255
#> Error in rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255): color intensity NA, not in 0:255

Created on 2019-04-03 by the reprex package (v0.2.1)

Two more questions come in mind: how can I specify which band is red, green o blue in the funcion (ej. plotRGB(., r=3, g=2, b=1)) and there is a possibility to streching the image (plotRGB(.stretch=c("hist","lin")) ?. I read documentation, vignettes and some questions on SO, but found little information about it.

(P.S. reprex package is awesome and tmap too!)

mtennekes commented 5 years ago

Are you using the lastest github version of tmap? Could you share this raster dataset, or reproduce this example with another dataset?

CamiloEr commented 5 years ago

The package was reinstalled from github and here I use a better fully reproducible example with Session Info.


library(tmap)
library(raster)
#> Loading required package: sp

#3 Layers with range 0-1
r <- raster(nrow=3, ncol=3)
set.seed(1)
s1 <- lapply(1:3, function(i) setValues(r, runif(ncell(r), 0, 1)))
x1 <- brick(s1)

plot(x1)

plotRGB(x1, r=1, g=2, b=3, stretch="lin") #Useful option for image enhancement

plotRGB(x1, r=1, g=2, b=3, scale=1)

tm_shape(x1)+
  tm_rgb(interpolate = FALSE, max.value = 1) #With max.value the problem of range 0-1 is resolved.
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3

#More than 3 layers with range 0-1
set.seed(1)
s2 <- lapply(1:5, function(i) setValues(r, runif(ncell(r), 0, 1))) #5 layers
x2 <- brick(s2)

plot(x2)

plotRGB(x2, r=1, g=2, b=3, scale=1)

plotRGB(x2, r=4, g=2, b=1, scale=1)  #Useful option for false color images

tm_shape(x2)+
  tm_rgb(interpolate = FALSE, max.value = 1) #With more than 3 layers the problem persist.
#> Error: Raster object does not have a color table, nor numeric data that can be converted to colors. Use tm_raster to visualize the data.

tm_shape(x2[[1:3]])+ 
  tm_rgb(interpolate = FALSE, max.value = 1) #It works for a subset of layers

tm_shape(x2[[1:4]])+ 
  tm_rgb(interpolate = FALSE, max.value = 1) #Strange result

tm_shape(x2[[c(4,2,1)]])+  #Workaround for false color images
  tm_rgb(interpolate = FALSE, max.value = 1)

Created on 2019-04-25 by the reprex package (v0.2.1)

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.5.2 (2018-12-20) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate Spanish_Colombia.1252 #> ctype Spanish_Colombia.1252 #> tz America/Bogota #> date 2019-04-25 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3) #> backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.2) #> callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3) #> class 7.3-14 2015-08-30 [2] CRAN (R 3.5.2) #> classInt 0.3-1 2018-12-18 [1] CRAN (R 3.5.2) #> cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3) #> codetools 0.2-15 2016-10-05 [2] CRAN (R 3.5.2) #> 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.3 2019-01-10 [1] CRAN (R 3.5.2) #> 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.2) #> 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-1 2019-03-19 [1] CRAN (R 3.5.3) #> evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.2) #> fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.3) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3) #> highr 0.8 2019-03-20 [1] CRAN (R 3.5.3) #> 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.5.0 2019-03-15 [1] CRAN (R 3.5.3) #> httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.2) #> KernSmooth 2.23-15 2015-06-29 [2] CRAN (R 3.5.2) #> knitr 1.22 2019-03-08 [1] CRAN (R 3.5.2) #> later 0.8.0 2019-02-11 [1] CRAN (R 3.5.2) #> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.5.2) #> leaflet 2.0.2 2018-08-27 [1] CRAN (R 3.5.1) #> leafsync 0.1.0 2019-03-05 [1] CRAN (R 3.5.3) #> lwgeom 0.1-6 2019-02-18 [1] CRAN (R 3.5.2) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.2) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.2) #> mime 0.6 2018-10-05 [1] CRAN (R 3.5.1) #> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.2) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.2) #> processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3) #> promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.1) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2) #> R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2) #> raster * 2.8-19 2019-01-30 [1] CRAN (R 3.5.2) #> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.5.0) #> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3) #> remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.2) #> rgdal 1.4-3 2019-03-14 [1] CRAN (R 3.5.3) #> rgeos 0.4-2 2018-11-08 [1] CRAN (R 3.5.1) #> rlang 0.3.3 2019-03-29 [1] CRAN (R 3.5.3) #> rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.3) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.2) #> sf * 0.7-3 2019-02-21 [1] CRAN (R 3.5.2) #> 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.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.3) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.2) #> testthat 2.0.1 2018-10-13 [1] CRAN (R 3.5.2) #> tmap * 2.3 2019-04-07 [1] Github (mtennekes/tmap@3b05198) #> tmaptools 2.0-1 2018-08-07 [1] CRAN (R 3.5.3) #> units 0.6-2 2018-12-05 [1] CRAN (R 3.5.2) #> usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.2) #> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.1) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1) #> xfun 0.6 2019-04-02 [1] CRAN (R 3.5.3) #> XML 3.98-1.19 2019-03-06 [1] CRAN (R 3.5.2) #> 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) #> #> [1] C:/Users/Camilo Erasso/Documents/R/win-library/3.5 #> [2] C:/Program Files/R/R-3.5.2/library ```

In the code I highlight two useful options that have raster::plotRGB and that could be useful in tmap: False Color Images and Image Enhancement . Some references: http://gsp.humboldt.edu/OLM/Courses/GSP_216_Online/lesson3-1/composites.html https://landsat.usgs.gov/what-are-band-designations-landsat-satellites https://www.nrcan.gc.ca/earth-sciences/geomatics/satellite-imagery-air-photos/satellite-imagery-products/educational-resources/9389

mtennekes commented 5 years ago

Thanks for your input!

How it currently works:

  1. Do you know how the image enhancement works? If you have some code already, you are welcome to contribute it to tmap.
  2. Regarding the scaling and false color images: how should the user be able to specify this? We could add arguments the same arguments, so r, g, b and scale, but maybe there are better alternatives.
  3. What shall we do with the alpha channel? If a user specifies 4 raster layers, is it okay to assume that the fourth represents transparency?
CamiloEr commented 5 years ago

Thank you for clarifying how this function works. Now everything is clearer. Regarding the other matters:

  1. The image enhancement options that the raster package use (ej. https://github.com/cran/raster/blob/master/R/stretch.R) are improved from this code: https://spatiallyexplicit.wordpress.com/2011/06/07/crop-circles/

These are the basic ones but I will explore others and will gladly share them by opening a new issue.

  1. In this aspect, the alternative to automate the use of these parameters (bands, scale factors, saturated values, etc.) is through the interpretation of the metadata files that come in .xml (or .txt) format with (some) satellite images. This is what ArcGIS/ArcMap does, for example. But this is too specific to the remote sensing area (although the RStoolboox package has functions that help in this regard (eg. getMeta()) http://bleutner.github.io/RStoolbox/rstbx-docu/).

So, because the configurations of the bands are so different beteween sensors, even between satellites of the same program (eg. Landsat7 with r = 3, g = 2 b = 1 and Landsat8 with r = 4, g = 3 b = 2, or MODIS with r = 1, g = 4 b = 3), the most direct way to indicate the position of the bands is through the arguments of the function (similar to raster::plotRGB(r,g,b)). The option r = 1, g = 2, b = 3 could be left as the default (this works on satellites such as Planet's RapidEye, for example). In addition, this arguments could be used to subset the rasterbrick (eg. brick[[r]]) to avoid the problem of using more than 4 layers.

  1. Honestly I have never used this argument to visualize satellite images. I only know that ArcGis/ArcMap also has it, but I do not know its use. The fourth most used band of the satellites I know is the NIR, but to explore this and other non-visible bands, the false color technique is used. I would leave this argumet but with default value NULL to avoid confusions like the one I had.

I hope that these contributions have helped and feel free to close this issue when you consider it necessary. My doubts have already been resolved.

mtennekes commented 5 years ago

Ok, thx!

I have made a start with the channels (https://github.com/mtennekes/tmap/commit/0002f6a5f5a89a552b46fb9edb76176c8362a6c8). I added tm_rgba which uses an alpha channel, so that tm_rgb is by default without alpha channel. The errors, warnings, and messages have already been improved.

Let me know if it works correctly. Are there any nice examples that we can add to the documentation, e.g. a small and accessible satellite image?

CamiloEr commented 5 years ago

Works perfect! :tada:

Here is an example from a data set that I borrowed from RStoolbox package. I also used that package to prove that everything works as expected. The Landsat images are free under subscription on https://earthexplorer.usgs.gov/ in case you don't want to use the RStoolbox data set (or I can send you another similar subset of an area of ​​interest used for other shapes examples in tmap).

library(RStoolbox)
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
library(tmap)
library(raster)
#> Loading required package: sp

data(lsat, package="RStoolbox")
(Landsat5 <- lsat) #It has 7 bands, e.g. B1_dn=blue, B2_dn=green, B3_dn=red, B4_dn=NIR
#> class       : RasterBrick 
#> dimensions  : 310, 287, 88970, 7  (nrow, ncol, ncell, nlayers)
#> resolution  : 30, 30  (x, y)
#> extent      : 619395, 628005, -419505, -410205  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, B7_dn 
#> min values  :    54,    18,    11,     4,     2,   131,     1 
#> max values  :   185,    87,    92,   127,   148,   146,    79

RStoolbox::ggRGB(Landsat5) #They use r = 3, g = 2, b = 1 as default

tm_shape(Landsat5)+
  tm_rgb(r = 3, g = 2, b = 1)

#This example is useful to see the utility of a image enhancement option:
RStoolbox::ggRGB(Landsat5, stretch = "lin") #They have other image enhancement options too ('sqrt' or 'log')

(Landsat5_linstretch <- raster::stretch(Landsat5, minq=0.02, maxq=0.98))
#> class       : RasterBrick 
#> dimensions  : 310, 287, 88970, 7  (nrow, ncol, ncell, nlayers)
#> resolution  : 30, 30  (x, y)
#> extent      : 619395, 628005, -419505, -410205  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, B7_dn 
#> min values  :     0,     0,     0,     0,     0,     0,     0 
#> max values  :   255,   255,   255,   255,   255,   255,   255

tm_shape(Landsat5_linstretch)+ #Works perfect!
  tm_rgb(r = 3, g = 2, b = 1)

#False color to highlight vegetation (in red) using B4_dn=NIR
tm_shape(Landsat5_linstretch)+ #Great job, thanks!
  tm_rgb(r = 4, g = 3, b = 2)

Created on 2019-05-05 by the reprex package (v0.2.1)

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.0 (2019-04-26) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate Spanish_Colombia.1252 #> ctype Spanish_Colombia.1252 #> tz America/Bogota #> date 2019-05-05 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3) #> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0) #> callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3) #> caret 6.0-83 2019-04-18 [1] CRAN (R 3.6.0) #> class 7.3-15 2019-01-01 [2] CRAN (R 3.6.0) #> classInt 0.3-3 2019-04-26 [1] CRAN (R 3.6.0) #> cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 3.6.0) #> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.5.3) #> 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.3 2019-01-10 [1] CRAN (R 3.5.2) #> data.table 1.12.2 2019-04-07 [1] CRAN (R 3.6.0) #> 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.2 2019-04-08 [1] CRAN (R 3.6.0) #> 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) #> doParallel 1.0.14 2018-09-24 [1] CRAN (R 3.5.1) #> dplyr 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.2) #> e1071 1.7-1 2019-03-19 [1] CRAN (R 3.5.3) #> evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.2) #> foreach 1.4.4 2017-12-12 [1] CRAN (R 3.5.1) #> fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.3) #> generics 0.0.2 2018-11-29 [1] CRAN (R 3.5.2) #> geosphere 1.5-7 2017-11-05 [1] CRAN (R 3.5.1) #> ggplot2 3.1.1 2019-04-07 [1] CRAN (R 3.5.2) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3) #> gower 0.2.0 2019-03-07 [1] CRAN (R 3.5.3) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.5.3) #> highr 0.8 2019-03-20 [1] CRAN (R 3.5.3) #> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0) #> htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.5.1) #> httpuv 1.5.1 2019-04-05 [1] CRAN (R 3.6.0) #> httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.2) #> ipred 0.9-8 2018-11-05 [1] CRAN (R 3.5.2) #> iterators 1.0.10 2018-07-13 [1] CRAN (R 3.5.1) #> KernSmooth 2.23-15 2015-06-29 [2] CRAN (R 3.6.0) #> knitr 1.22 2019-03-08 [1] CRAN (R 3.5.2) #> labeling 0.3 2014-08-23 [1] CRAN (R 3.5.0) #> later 0.8.0 2019-02-11 [1] CRAN (R 3.5.2) #> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.0) #> lava 1.6.5 2019-02-12 [1] CRAN (R 3.5.2) #> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.5.3) #> leaflet 2.0.2 2018-08-27 [1] CRAN (R 3.5.1) #> leafsync 0.1.0 2019-03-05 [1] CRAN (R 3.5.3) #> lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.5.1) #> lwgeom 0.1-6 2019-02-18 [1] CRAN (R 3.5.2) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.2) #> MASS 7.3-51.4 2019-03-31 [2] CRAN (R 3.6.0) #> Matrix 1.2-17 2019-03-22 [2] CRAN (R 3.6.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.2) #> mime 0.6 2018-10-05 [1] CRAN (R 3.5.1) #> ModelMetrics 1.2.2 2018-11-03 [1] CRAN (R 3.5.3) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.1) #> nlme 3.1-139 2019-04-09 [2] CRAN (R 3.6.0) #> nnet 7.3-12 2016-02-02 [2] CRAN (R 3.6.0) #> pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.2) #> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3) #> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.1) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.2) #> plyr 1.8.4 2016-06-08 [1] CRAN (R 3.5.1) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.2) #> processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3) #> prodlim 2018.04.18 2018-04-18 [1] CRAN (R 3.5.2) #> promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.1) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2) #> purrr 0.3.2 2019-03-15 [1] CRAN (R 3.5.3) #> R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2) #> raster * 2.8-19 2019-01-30 [1] CRAN (R 3.5.2) #> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.5.0) #> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3) #> recipes 0.1.5 2019-03-21 [1] CRAN (R 3.5.3) #> remotes 2.0.4 2019-04-10 [1] CRAN (R 3.6.0) #> reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.5.1) #> rgdal 1.4-3 2019-03-14 [1] CRAN (R 3.5.3) #> rgeos 0.4-3 2019-04-24 [1] CRAN (R 3.6.0) #> rlang 0.3.4 2019-04-07 [1] CRAN (R 3.6.0) #> rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.3) #> rpart 4.1-15 2019-04-12 [2] CRAN (R 3.6.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1) #> RStoolbox * 0.2.4 2019-01-08 [1] CRAN (R 3.5.3) #> scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.2) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.2) #> sf 0.7-4 2019-04-25 [1] CRAN (R 3.6.0) #> shiny 1.3.2 2019-04-22 [1] CRAN (R 3.6.0) #> sp * 1.3-1 2018-06-05 [1] CRAN (R 3.5.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.3) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.2) #> survival 2.44-1.1 2019-04-01 [2] CRAN (R 3.6.0) #> testthat 2.1.1 2019-04-23 [1] CRAN (R 3.6.0) #> tibble 2.1.1 2019-03-16 [1] CRAN (R 3.5.3) #> tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.1) #> timeDate 3043.102 2018-02-21 [1] CRAN (R 3.5.2) #> tmap * 2.3 2019-05-05 [1] Github (mtennekes/tmap@0002f6a) #> tmaptools 2.0-1 2018-08-07 [1] CRAN (R 3.5.3) #> units 0.6-3 2019-05-03 [1] CRAN (R 3.6.0) #> usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.2) #> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.1) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1) #> xfun 0.6 2019-04-02 [1] CRAN (R 3.5.3) #> XML 3.98-1.19 2019-03-06 [1] CRAN (R 3.5.2) #> xml2 1.2.0 2018-01-24 [1] CRAN (R 3.5.1) #> xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.1) #> #> [1] C:/Users/Camilo Erasso/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.0/library ```
mtennekes commented 5 years ago

Thx @CamiloEr

Yes, I am looking for such an example for the documentation without having to suggest another package. Is there a url somewhere which directly refers to such an object? We could also include such an object in tmap. Saved as rda object with compres = "xz", Landsat5 occupies 280Kb. However, it will only be used in tm_rgb since all other datasets in tmap cover much larger areas.

Regarding the stretch function. I thought about embedding it in tmap, but I think this is not a very good idea since the long term plan is to replace raster by stars. Probably better to keep this function as is. We could also show how it works in the examples, since tmap still imports raster.

mtennekes commented 2 years ago

Cleaning up all issues that are not relevant for the first release of tmap v4.