Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need ID builder for pairs of tables #136

Open
1 task
mdsumner opened this issue May 12, 2021 · 0 comments
Open
1 task

need ID builder for pairs of tables #136

mdsumner opened this issue May 12, 2021 · 0 comments

Comments

@mdsumner
Copy link
Member

SC0() is pretty fast, but SC() is very slow - unpack

  • building the object_link_edge table from SC0

WIP

f <- raadfiles::thelist_files(pattern = "parcels_hobart")$fullname

sfx <- sf::read_sf(f)
idx <- sort(unique(unlist(sf::st_touches(sfx[1:10, ], sfx))))
library(dplyr)

sc0 <- silicate::SC0(sfx[idx, ])
#system.time(sc <- silicate::SC(sc0))
system.time(
## flesh out the edge pairs, and unique id them
edge <- bind_rows(sc0$object$topology_, .id = "object") %>% 
  mutate(min = pmin(.vx0, .vx1), max = pmax(.vx0, .vx1), native_ = min == .vx0) %>% 
  dplyr::group_by(min, max) %>% 
  dplyr::mutate(edge = dplyr::cur_group_id()) %>% 
  dplyr::ungroup() %>% 
  dplyr::select(.vx0, .vx1, path_, edge, object, native_)
)

sc2 <- silicate::SC(sc0)
ams <- function(x, y) as.character(match(x, y))
sc2$object_link_edge$object_ <- ams(sc2$object_link_edge$object_, sc2$object$object_)
sc2$object$object_ <- as.character(1:nrow(sc2$object))

sc2$object_link_edge$edge_ <- ams(sc2$object_link_edge$edge_, sc2$edge$edge_)
sc2$edge$edge_ <- as.character(1:nrow(sc2$edge))

sc2$edge$.vx0 <- ams(sc2$edge$.vx0, sc2$vertex$vertex_)
sc2$edge$.vx1 <- ams(sc2$edge$.vx1, sc2$vertex$vertex_)
sc2$vertex$vertex_ <- as.character(1:nrow(sc2$vertex))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
-