ropensci / osmdata

R package for downloading OpenStreetMap data
https://docs.ropensci.org/osmdata
317 stars 45 forks source link

How to join sc object together ? #333

Closed xtimbeau closed 1 year ago

xtimbeau commented 1 year ago

Hi, thanks for this package. I am trying to build up a silicate extract of some OSM data to be used in dodgr. I used the vignette "splitting large queries" but I fail to do the final merge. There seems to be no method for c for SC or osmdata_sc class. Am I missing something ?

mpadge commented 1 year ago

Thanks @xtimbeau, you were right that we had neglected to implement the c.osmdata_sc method. The above commit does that, and you should now be able to do this:

library (osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
packageVersion ("osmdata")
#> [1] '0.2.5.4'

x1 <- opq (bbox = "maldon australia") |>
    add_osm_feature (key = "natural") |>
    osmdata_sc ()
x2 <- opq (bbox = "maldon australia") |>
    add_osm_feature (key = "leisure") |>
    osmdata_sc ()

x12 <- c (x1, x2)

sapply (x1, nrow)
#>               nodes    relation_members relation_properties              object 
#>                 347                  13                  13                 287 
#>    object_link_edge                edge              vertex                meta 
#>                3190                3190                3450                   1
sapply (x2, nrow)
#>               nodes    relation_members relation_properties              object 
#>                   2                   4                  26                 148 
#>    object_link_edge                edge              vertex                meta 
#>                 591                 591                 576                   1
sapply (x12, nrow)
#>               nodes    relation_members relation_properties              object 
#>                 349                  17                  39                 432 
#>    object_link_edge                edge              vertex                meta 
#>                3781                3781                3984                   1

Created on 2023-10-06 with reprex v2.0.2

xtimbeau commented 1 year ago

Great many thanks it worked !

Le ven. 6 oct. 2023 à 11:38, mark padgham @.***> a écrit :

Thanks @xtimbeau https://github.com/xtimbeau, you were right that we had neglected to implement the c.osmdata_sc method. The above commit does that, and you should now be able to do this:

library (osmdata)#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright packageVersion ("osmdata")#> [1] '0.2.5.4' x1 <- opq (bbox = "maldon australia") |> add_osm_feature (key = "natural") |> osmdata_sc ()x2 <- opq (bbox = "maldon australia") |> add_osm_feature (key = "leisure") |> osmdata_sc () x12 <- c (x1, x2)

sapply (x1, nrow)#> nodes relation_members relation_properties object #> 347 13 13 287 #> object_link_edge edge vertex meta #> 3190 3190 3450 1 sapply (x2, nrow)#> nodes relation_members relation_properties object #> 2 4 26 148 #> object_link_edge edge vertex meta #> 591 591 576 1 sapply (x12, nrow)#> nodes relation_members relation_properties object #> 349 17 39 432 #> object_link_edge edge vertex meta #> 3781 3781 3984 1

Created on 2023-10-06 with reprex v2.0.2 https://reprex.tidyverse.org

— Reply to this email directly, view it on GitHub https://github.com/ropensci/osmdata/issues/333#issuecomment-1750291571, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANA2KEJBYPZS3XV6QSKT65LX57GP5AVCNFSM6AAAAAA5VM34ESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQGI4TCNJXGE . You are receiving this because you were mentioned.Message ID: @.***>