luukvdmeer / sfnetworks

Tidy Geospatial Networks in R
https://luukvdmeer.github.io/sfnetworks/
Other
345 stars 20 forks source link

Quiet option to skip validity text #261

Closed latot closed 2 months ago

latot commented 9 months ago

Hi all, I think would be great a quiet option for functions like sfnetwork and as_sfnetwork, they actually have this messages:

Checking if spatial network structure is valid...
Spatial network structure is valid

Which can be helpful when we are using sfnetworks manually, but in a lib or tests do the things more complex, if we use a lot of networks to test, we end having a lot of that text all over the place.

There is an option to skip the validation, which is different to this issue, I think the best is be able to run the network validation without this messages, and if is not valid, then throw an error.

Thx!

agila5 commented 2 months ago

Hi @latot! The feature you requested is available starting from version 0.6.4

library(sf)
#> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(sfnetworks)

p1 = st_point(c(7, 51))
p2 = st_point(c(7, 52))
l1 = st_sfc(st_linestring(c(p1, p2)))

edges = st_as_sf(l1, crs = 4326)
nodes = st_as_sf(c(st_sfc(p1), st_sfc(p2)), crs = 4326)
edges$from = c(1)
edges$to = c(2)

sfn <- sfnetwork(nodes, edges, message = FALSE)

Created on 2024-07-12 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.1 (2023-06-16 ucrt) #> os Windows 11 x64 (build 22631) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United Kingdom.utf8 #> ctype English_United Kingdom.utf8 #> tz Europe/Rome #> date 2024-07-12 #> pandoc 3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-5 2016-07-21 [1] CRAN (R 4.3.1) #> class 7.3-22 2023-05-03 [2] CRAN (R 4.3.1) #> classInt 0.4-10 2023-09-05 [1] CRAN (R 4.3.1) #> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.3) #> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.1) #> crayon 1.5.3 2024-06-20 [1] CRAN (R 4.3.3) #> DBI 1.2.2 2024-02-16 [1] CRAN (R 4.3.3) #> deldir 1.0-9 2023-05-17 [1] CRAN (R 4.3.1) #> digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.3) #> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.3.1) #> e1071 1.7-14 2023-12-06 [1] CRAN (R 4.3.2) #> evaluate 0.24.0 2024-06-10 [1] CRAN (R 4.3.3) #> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.2) #> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.3.3) #> fs 1.6.4 2024-04-25 [1] CRAN (R 4.3.3) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.1) #> ggplot2 3.5.1.9000 2024-05-25 [1] Github (tidyverse/ggplot2@28aec3a) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2) #> goftest 1.2-3 2021-10-07 [1] CRAN (R 4.3.1) #> gtable 0.3.5 2024-04-22 [1] CRAN (R 4.3.1) #> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.3.3) #> igraph 2.0.3 2024-03-13 [1] CRAN (R 4.3.1) #> KernSmooth 2.23-21 2023-05-03 [2] CRAN (R 4.3.1) #> knitr 1.48 2024-07-07 [1] CRAN (R 4.3.3) #> lattice 0.21-8 2023-04-05 [2] CRAN (R 4.3.1) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2) #> lwgeom 0.2-13 2023-05-22 [1] CRAN (R 4.3.1) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.1) #> Matrix 1.6-1.1 2023-09-18 [1] CRAN (R 4.3.1) #> mgcv 1.9-1 2023-12-21 [1] CRAN (R 4.3.1) #> munsell 0.5.1 2024-04-01 [1] CRAN (R 4.3.3) #> nlme 3.1-162 2023-01-31 [2] CRAN (R 4.3.1) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.1) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.1) #> polyclip 1.10-6 2023-09-27 [1] CRAN (R 4.3.1) #> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.3.1) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.1) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.1) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.3.1) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.3.1) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.1) #> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.1) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.3.1) #> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.1) #> rmarkdown 2.27 2024-05-17 [1] CRAN (R 4.3.3) #> rpart 4.1.19 2022-10-21 [2] CRAN (R 4.3.1) #> rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.3.1) #> s2 1.1.6 2024-02-05 [1] Github (r-spatial/s2@ff89074) #> scales 1.3.0 2023-11-28 [1] CRAN (R 4.3.1) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.1) #> sf * 1.0-16 2024-03-17 [1] Github (r-spatial/sf@67d41e4) #> sfheaders 0.4.4 2024-01-17 [1] CRAN (R 4.3.3) #> sfnetworks * 0.6.4 2024-04-09 [1] CRAN (R 4.3.1) #> spatstat.data 3.0-4 2024-01-15 [1] CRAN (R 4.3.1) #> spatstat.explore 3.2-7 2024-03-21 [1] CRAN (R 4.3.1) #> spatstat.geom 3.2-9 2024-02-28 [1] CRAN (R 4.3.1) #> spatstat.linnet 3.1-5 2024-03-25 [1] CRAN (R 4.3.1) #> spatstat.model 3.2-11 2024-03-22 [1] CRAN (R 4.3.1) #> spatstat.random 3.2-3 2024-02-29 [1] CRAN (R 4.3.1) #> spatstat.sparse 3.0-3 2023-10-24 [1] CRAN (R 4.3.1) #> spatstat.utils 3.0-5 2024-06-17 [1] CRAN (R 4.3.1) #> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.1) #> tensor 1.5 2012-05-05 [1] CRAN (R 4.3.1) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.1) #> tidygraph 1.2.3 2023-02-01 [1] CRAN (R 4.3.1) #> tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.3.1) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.1) #> units 0.8-5.4 2024-06-03 [1] local #> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.1) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2) #> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.1) #> wk 0.9.1 2023-11-29 [1] CRAN (R 4.3.2) #> xfun 0.45 2024-06-16 [1] CRAN (R 4.3.3) #> yaml 2.3.9 2024-07-05 [1] CRAN (R 4.3.3) #> #> [1] C:/Users/user/AppData/Local/R/win-library/4.3 #> [2] C:/Program Files/R/R-4.3.1/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

Therefore, I think we can close this issue for the time being.

latot commented 2 months ago

:O Thx!