{"action":"created","issue":{"url":"https://api.github.com/repos/r-spatial/sf/issues/715","repository_url":"https://api.github.com/repos/r-spatial/sf","labels_url":"https://api.github.com/repos/r-spatial/sf/issues/715/labels{/name}","comments_url":"https://api.github.com/repos/r-spatial/sf/issues/715/comments","events_url":"https://api.github.com/repos/r-spatial/sf/issues/715/events","html_url":"https://github.com/r-spatial/sf/issues/715","id":316032876,"number":715,"title":"How to convert sparse result of a predicate to a graph?","user":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars0.githubusercontent.com/u/1741643?v=4","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-19T20:41:36Z","updated_at":"2018-04-23T18:31:52Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I haven't found a good way to convert the return of `st_intersects()` to a graph for computing connected components. Ultimately, I created an edgelist manually and passed it to `igraph::graph_from_edgelist()`. Have I missed anything obvious?\r\n\r\n``` r\r\nlibrary(tidyverse)\r\nlibrary(sf)\r\n#> Linking to GEOS 3.5.1, GDAL 2.2.1, proj.4 4.9.3\r\n\r\nrel <- \r\n  tibble(\r\n    key = 1:3,\r\n    geom = map2(1:3, c(2:3, 5), c) %>% map(st_point) %>% st_sfc()\r\n  ) %>% \r\n  st_as_sf() %>% \r\n  st_buffer(0.8) %>%\r\n  st_intersects()\r\n\r\nrel\r\n#> Sparse geometry binary predicate list of length 3, where the predicate was `intersects'\r\n#>  1: 1, 2\r\n#>  2: 1, 2\r\n#>  3: 3\r\n\r\nmatrix(\r\n  c(\r\n    rep(seq_along(rel), map_int(rel, length)),\r\n    unlist(rel)\r\n  ),\r\n  ncol = 2\r\n) %>% \r\n  igraph::graph_from_edgelist() %>% \r\n  igraph::components()\r\n#> $membership\r\n#> [1] 1 1 2\r\n#> \r\n#> $csize\r\n#> [1] 2 1\r\n#> \r\n#> $no\r\n#> [1] 2\r\n```\r\n\r\nCreated on 2018-04-19 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0)."},"comment":{"url":"https://api.github.com/repos/r-spatial/sf/issues/comments/383676994","html_url":"https://github.com/r-spatial/sf/issues/715#issuecomment-383676994","issue_url":"https://api.github.com/repos/r-spatial/sf/issues/715","id":383676994,"user":{"login":"edzer","id":520851,"avatar_url":"https://avatars1.githubusercontent.com/u/520851?v=4","gravatar_id":"","url":"https://api.github.com/users/edzer","html_url":"https://github.com/edzer","followers_url":"https://api.github.com/users/edzer/followers","following_url":"https://api.github.com/users/edzer/following{/other_user}","gists_url":"https://api.github.com/users/edzer/gists{/gist_id}","starred_url":"https://api.github.com/users/edzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edzer/subscriptions","organizations_url":"https://api.github.com/users/edzer/orgs","repos_url":"https://api.github.com/users/edzer/repos","events_url":"https://api.github.com/users/edzer/events{/privacy}","received_events_url":"https://api.github.com/users/edzer/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T18:31:52Z","updated_at":"2018-04-23T18:31:52Z","author_association":"OWNER","body":"A candidate for an `as.igraph.sgbp` method?"}}
{"actor":{"display_login":"edzer"}}