opengeos / whiteboxR

WhiteboxTools R Frontend
https://whiteboxR.gishub.org
Other
168 stars 30 forks source link

Make visible warning messages in interactive/verbose mode #77

Closed brownag closed 2 years ago

brownag commented 2 years ago

This does not generate actual R warnings. It also does not change the character result -- it is still (should be) tool name and elapsed time when a warning is issued; character of length 1.

Two examples:

library(sf)
library(terra)
library(soilDB)
library(whitebox)

wbt_verbose(TRUE)
m <- SDA_spatialQuery(st_as_sfc('POLYGON((-120.4712 37.9501,-120.4712 37.9625,-120.4369 37.9625,-120.4369 37.9501,-120.4712 37.9501))', 4326), what = 'mupolygon', geomIntersection = TRUE)

m$foo <- letters[1:nrow(m)]
write_sf(m, "test.shp")

wbt_vector_polygons_to_raster("./test.shp", "./test.tif", field = 'foo', cell_size = 0.001)
#> Warning: Non-numeric attributes cannot be directly assigned to raster data. A key will be established.
#> vector_polygons_to_raster - Elapsed Time (excluding I/O): 0.1s
library(terra)
library(whitebox)
wbt_verbose(TRUE)

writeRaster(rast(matrix(
  c(2, 2, 1, 1, 1,
    2, 1, 1, 0, 1,
    1, 1, 1, 1, 1),
  ncol = 5, byrow = TRUE
), crs = "EPSG:4326"), filename = "test.tif")

wbt_fd8_flow_accumulation("test.tif", "test2.tif")
#> **********************************************************************************
#> WARNING: Interior pit cells were found within the input DEM. It is likely that the 
#>             DEM needs to be processed to remove topographic depressions and flats prior to
#>             running this tool.
#> **********************************************************************************
#> fd8_flow_accumulation - Elapsed Time (excluding I/O): 0.0s