luukvdmeer / sfnetworks

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

Add message argument to sfnetwork() #263

Closed agila5 closed 3 months ago

agila5 commented 7 months ago

The message argument can be used to silence the messages that are printed when checking the network validity:

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)
#> Checking if spatial network structure is valid...
#> Spatial network structure is valid
sfn <- sfnetwork(nodes, edges, message = FALSE)

Created on 2023-12-14 with reprex v2.0.2

Ref #261

(btw: I'm not sure why Rstudio decided to change the indentation in some paragraphs... Moreover, feel free to rename the new argument as quiet or something else).

luukvdmeer commented 3 months ago

This is added to the new minor version, thanks! https://github.com/luukvdmeer/sfnetworks/commit/6a151136085aac6a633845d0be6fe52b1aed5819