diff --git a/.Rbuildignore b/.Rbuildignore index 7774aab6baf737a9b229db233063b06ee895427b..829fb75bd410468d8d5ea0c671ea145096003170 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,6 +2,8 @@ ^\.Rproj\.user$ package.json package-lock.json +settings.json +vignettes/settings.json node_modules ^doc$ ^Meta$ diff --git a/.gitignore b/.gitignore index 4691b381f0a5930fefeacf3498331420eea13acf..5d5492061052e4b9f4ac14b0255ee009618ccdec 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ MD5 node_modules package.json package-lock.json +settings.json diff --git a/DESCRIPTION b/DESCRIPTION index e77f5ecf9993a8e841b8c62e9ff61fdb797a2ab4..03fd4bb7eb4ba7008aaab10e015923005f883654 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: transfR Type: Package Title: Transfer of Hydrograph from Gauged to Ungauged Catchments Version: 1.0.7 -Date: 2023-01-23 +Date: 2023-01-24 Authors@R: c( person("Alban", "de Lavenne", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9448-3490"), email = "alban.delavenne@inrae.fr"), person("Christophe", "Cudennec", role = c("ths"), comment = c(ORCID = "0000-0002-1707-8926"), email = "christophe.cudennec@agrocampus-ouest.fr"), diff --git a/vignettes/V03_inputs_preparation_whitebox.Rmd b/vignettes/V03_inputs_preparation_whitebox.Rmd index 60466cf005c2be2040abc5c193ab5cc1fa0c920c..ff6bb2a1fe10ade9b664b8c71d1eaf7603520faf 100644 --- a/vignettes/V03_inputs_preparation_whitebox.Rmd +++ b/vignettes/V03_inputs_preparation_whitebox.Rmd @@ -40,7 +40,7 @@ The `elevatr` package allows retrieving grids (rasters) of elevation data worldw It is necessary to assign a geographic projection for the catchment delineation and hydraulic length maps with the `whitebox` package. We chose to use the Lambert93 projection, the official projection for maps of metropolitan France, for which the [EPSG code is 2154](https://epsg.io/2154). -```{r, download_dem, echo=TRUE, message=FALSE, warning=FALSE, eval=TRUE, results='hide'} +```{r, download_dem, echo=TRUE, message=FALSE, warning=FALSE, eval=FALSE, results='hide'} library(elevatr) library(rgdal) # Still often needed by elevatr library(progress) # Still often needed by elevatr @@ -107,7 +107,7 @@ if(!wbt_init()){ } ``` -```{r, burn_stream, echo=TRUE, message=FALSE, warning=FALSE, eval=running, results='hide'} +```{r, burn_stream, echo=TRUE, message=FALSE, warning=FALSE, eval=FALSE, results='hide'} library(transfR) library(whitebox) @@ -158,7 +158,7 @@ The `whitebox` package provides all the tools to perform a usual catchment delin * [Delimit the catchments](https://www.whiteboxgeo.com/manual/wbt_book/available_tools/hydrological_analysis.html#Watershed). -```{r, extract_stream, echo=TRUE, message=FALSE, warning=FALSE, eval=running, results='hide'} +```{r, extract_stream, echo=TRUE, message=FALSE, warning=FALSE, eval=FALSE, results='hide'} # Remove the depressions on the DEM whitebox::wbt_fill_depressions(dem = "dem_100m_burn.tif", output = "dem_fill.tif", @@ -200,7 +200,7 @@ if(inherits(try_chunk, "try-error")){ Coordinates of the outlets are retrieved from [hydro.eaufrance.fr](https://www.hydro.eaufrance.fr/) and snapped to the pixel of the river network that is consistent with the previously defined flow directions. -```{r, delineate_catchments, echo=TRUE, message=FALSE, warning=FALSE, eval=running, results='hide'} +```{r, delineate_catchments, echo=TRUE, message=FALSE, warning=FALSE, eval=FALSE, results='hide'} # Localize the outlets of the studied catchments (with manual adjustments to help snapping) outlets_coordinates <- data.frame(id = names(Blavet$hl), X = c(254010.612,255940-100,255903,237201,273672,265550), @@ -228,9 +228,9 @@ for(id in outlets_snapped$id){ wd = wbt_wd) # Vectorize catchments drainage <- read_stars(file.path(wbt_wd, paste0(id, "_catchment.tif"))) - contours <- st_contour(drainage, breaks = 1) |> st_cast("POLYGON") - contours <- contours[which.max(st_area(contours)),] - catchments <- rbind(catchments, st_sf(data.frame(id, geom = st_geometry(contours)))) + contours <- st_contour(drainage, breaks = 1) |> st_geometry() |> st_cast("POLYGON") + contours <- contours[which.max(st_area(contours))] + catchments <- rbind(catchments, st_sf(data.frame(id, geom = contours))) } ``` @@ -274,7 +274,7 @@ The `whitebox` package does not provide a function to compute hydraulic length d Flow path lengths are computed once for all the study area. For each catchment, this raster is then trimmed (i.e. removing NA values outside the bounding box of the catchment) and the values of flow path lengths are corrected such as the minimum flow path length is equal to half a pixel width/height. The hydraulic lengths are finally gathered in a list as expected by the `as_transfr()` function. -```{r, hydraulic_length, echo=TRUE, message=FALSE, warning=FALSE, eval=running, results='hide'} +```{r, hydraulic_length, echo=TRUE, message=FALSE, warning=FALSE, eval=FALSE, results='hide'} # Compute hydraulic length whitebox::wbt_downslope_flowpath_length(d8_pntr = "d8.tif", output = "fpl.tif",