mkkallio / hydrostreamer Goto Github PK
View Code? Open in Web Editor NEWR package for downscaling off-the-shelf runoff products to explicit river network.
Home Page: https://mkkallio.github.io/hydrostreamer/
License: MIT License
R package for downscaling off-the-shelf runoff products to explicit river network.
Home Page: https://mkkallio.github.io/hydrostreamer/
License: MIT License
Error in raster_to_HS(runoff, date = getZ(runoff), ...
length(date) != length(rasters)
This occurs because length(date) is equal to number of layers, but length(rasters)=1
hydrostreamer/R/raster_to_HSgrid.R
Lines 46 to 49 in 4c78053
hydrostreamer/R/raster_to_HSgrid.R
Lines 70 to 74 in 4c78053
A workaround specific to this input case is to replace L73 with:
test <- length(date) == nlayers(rasters[[1]])
It might be worth adding testthat cases covering common data ingestion to ensure there are no regressions.
I am running into a tibble error when I run river_network function. The error "! The validate
argument of as_tibble()
was deprecated in tibble 2.0.0 and is now
defunct.
โน Please use the .name_repair
argument instead."
How can I resolve this?
An error is thrown when strahler based weighting is used via compute_HSweights().
Traceback of Voronoi weighting with coordinates in degrees:
Error in CPL_geos_voronoi(x, st_sfc(envelope), dTolerance = dTolerance, :
Evaluation error: TopologyException: Input geom 1 is invalid: Self-intersection at or near point 105.5125000008 15.5708336588 at 105.5125000008 15.5708336588.
18.
stop(structure(list(message = "Evaluation error: TopologyException: Input geom 1 is invalid: Self-intersection at or near point 105.5125000008 15.5708336588 at 105.5125000008 15.5708336588.",
call = CPL_geos_voronoi(x, st_sfc(envelope), dTolerance = dTolerance,
bOnlyEdges = bOnlyEdges), cppstack = NULL), class = c("Rcpp::eval_error",
"C++Error", "error", "condition")))
17.
CPL_geos_voronoi(x, st_sfc(envelope), dTolerance = dTolerance,
bOnlyEdges = bOnlyEdges)
16.
st_sfc(CPL_geos_voronoi(x, st_sfc(envelope), dTolerance = dTolerance,
bOnlyEdges = bOnlyEdges))
15.
st_voronoi.sfc(sf::st_union(vorPoints), bbox, dTolerance = 0.1)
14.
sf::st_voronoi(sf::st_union(vorPoints), bbox, dTolerance = 0.1)
13.
eval(lhs, parent, parent)
12.
eval(lhs, parent, parent)
11.
sf::st_voronoi(sf::st_union(vorPoints), bbox, dTolerance = 0.1) %>%
sf::st_cast() %>% sf::st_cast("POLYGON") %>% sf::st_sf() %>%
sf::st_join(vorPoints) %>% lwgeom::st_make_valid() %>% dplyr::group_by_(riverID) %>%
dplyr::summarise() %>% sf::st_intersection(sf::st_geometry(aoi))
10.
withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
9.
suppressWarnings(sf::st_voronoi(sf::st_union(vorPoints), bbox,
dTolerance = 0.1) %>% sf::st_cast() %>% sf::st_cast("POLYGON") %>%
sf::st_sf() %>% sf::st_join(vorPoints) %>% lwgeom::st_make_valid() %>%
dplyr::group_by_(riverID) %>% dplyr::summarise() %>% sf::st_intersection(sf::st_geometry(aoi)))
8.
withCallingHandlers(expr, message = function(c) invokeRestart("muffleMessage"))
7.
suppressMessages(suppressWarnings(sf::st_voronoi(sf::st_union(vorPoints),
bbox, dTolerance = 0.1) %>% sf::st_cast() %>% sf::st_cast("POLYGON") %>%
sf::st_sf() %>% sf::st_join(vorPoints) %>% lwgeom::st_make_valid() %>%
dplyr::group_by_(riverID) %>% dplyr::summarise() %>% sf::st_intersection(sf::st_geometry(aoi)))) at C:\Users\Vili\AppData\Local\Temp\RtmpiAXEnH\file1e587c4c7dfc#20
6.
river_voronoi(river, aoi, verbose = verbose)
5.
compute_weights(rivers, grid, "area", aoi = st_sf(bbox), riverID = "SegmentID",
verbose = show_hs_output) at ucscript.R#102
4.
eval(ei, envir)
3.
eval(ei, envir)
2.
withVisible(eval(ei, envir))
1.
source("C:/Users/Vili/hydrostreamer/uncertainty/ucscript.R")
Suppose raster_to_HS is called with a vector date
and no timestep
, which should be possible:
raster_to_HS(runoff, date = getZ(runoff),...)
Error is thrown:
Error in if (timestep == "month") { : argument is of length zero
Cause
As per #5, a brick is ingested as rasters=list(runoff)
, so within the rasters loop, rast=1
hydrostreamer/R/raster_to_HSgrid.R
Line 99 in 4c78053
dates
is therefore always length 1, the vector date is not used, and timestep is queried when it shouldn't be needed:
hydrostreamer/R/raster_to_HSgrid.R
Lines 159 to 162 in 4c78053
Case specific workaround
Rewrite L159 to use dates
directly - unlisted with purr::reduce because it's not clear why a list is needed here and unlist clobbers dates
dates <- reduce(date,c)
Also fix L174 to throw error on !test
hydrostreamer/R/raster_to_HSgrid.R
Lines 173 to 175 in 4c78053
If there are river segments which do not fall in any of the runoff polygons, computing weights fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.