luukvdmeer / sfnetworks

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

Fix typo in create_nodes_from_edges #55

Closed agila5 closed 4 years ago

agila5 commented 4 years ago

Old behaviour:

# packages
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(sfnetworks)

# data
test <- st_sf(
  geom = st_sfc(
    st_linestring(rbind(c(0, 0), c(1, 0)))
  )
)
as_sfnetwork(test)
#> Error in add_vertices(gr, nrow(nodes) - gorder(gr)): At type_indexededgelist.c:369 : cannot add negative number of vertices, Invalid value

Created on 2020-06-12 by the reprex package (v0.3.0)

Fix typo:

# packages
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(sfnetworks)

# data
test <- st_sf(
  geom = st_sfc(
    st_linestring(rbind(c(0, 0), c(1, 0)))
  )
)
as_sfnetwork(test)
#> # An sfnetwork with 2 nodes and 1 edges
#> #
#> # CRS:  NA 
#> #
#> # A rooted tree with spatially explicit edges
#> #
#> # Node Data:     2 x 1 (active)
#> # Geometry type: POINT
#> # Dimension:     XY
#> # Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 0
#>      geom
#>   <POINT>
#> 1   (0 0)
#> 2   (1 0)
#> #
#> # Edge Data:     1 x 3
#> # Geometry type: LINESTRING
#> # Dimension:     XY
#> # Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 0
#>    from    to         geom
#>   <int> <int> <LINESTRING>
#> 1     1     2   (0 0, 1 0)

Created on 2020-06-12 by the reprex package (v0.3.0)

I know that this is trivial but I'm not 100% that I can commit to "develop" without ruining your local development (and this is probably the most important part of this PR so I can understand properly how to contribute 😅).