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

sc_segment() gives the SC index not SC0 #139

Open
mdsumner opened this issue Sep 20, 2021 · 1 comment
Open

sc_segment() gives the SC index not SC0 #139

mdsumner opened this issue Sep 20, 2021 · 1 comment

Comments

@mdsumner
Copy link
Member

sc_edge() is ok

silicate::sc_segment(silicate::SC0(tr))
# A tibble: 10,853 × 7
   object_ edge_  native_ .vx0   .vx1   path_ segment_
   <chr>   <chr>  <lgl>   <chr>  <chr>  <int> <chr>   
 1 erY36j  i85ZFS TRUE    aXrqMr Wc13d3     1 jrw9Mu  
 2 erY36j  i5gsKD TRUE    Wc13d3 Pp2x9a     1 8PNh6B  
 3 erY36j  VhQr0y TRUE    Pp2x9a DS3z6B     1 UlxXwD  
 4 erY36j  zi94aU TRUE    DS3z6B 2yMcaK     1 2NjKES  
 5 erY36j  RukRfJ TRUE    2yMcaK rfRHuq     1 swaWpG  
 6 erY36j  8Si0Qg TRUE    rfRHuq 1mLf2H     1 DDiH7Y  
 7 erY36j  5GVcOS TRUE    1mLf2H DQM8fd     1 lH38H9  
 8 erY36j  eWvDwS TRUE    DQM8fd kXNVWt     1 TWdXwh  
 9 erY36j  JNQCIh TRUE    kXNVWt TGRnNE     1 5LRqX2  
10 erY36j  Y0XAjf TRUE    TGRnNE MkfeJN     1 MF1Bln  
# … with 10,843 more rows
> silicate::sc_edge(silicate::SC0(tr))
# A tibble: 10,853 × 3
    .vx0  .vx1 path_
   <int> <int> <int>
 1  1821  2678     1
 2  2678  4780     1
 3  4780  5853     1
@mdsumner
Copy link
Member Author

motivating use case is time intervals on trip objects, using segments()

tr <- trip(d %>% dplyr::select(X, Y, Date, Nest))
segs <- silicate::SC0(tr)
## splat out to a df for segments
segs <- bind_rows(segs$object$topology_, .id = "object") %>%
  inner_join(segs$vertex %>% transmute(vertex_ = row_number(), x0 = x_, y0 = y_, starttime = t_), c(".vx0" = "vertex_")) %>%
  inner_join(segs$vertex %>% transmute(vertex_ = row_number(), x1 = x_, y1 = y_, endtime = t_), c(".vx1" = "vertex_")) %>%
  dplyr::select(object, x0, y0, starttime, x1, y1, endtime)
segs$color_ <- palr::d_pal(segs$object)

...

 segs2 <- dplyr::filter(segs, endtime <= (dts[i]) & starttime >= (dts[i] - 3 * 24 * 3600))
  with(segs2, segments(x0, y0, x1, y1, col = color_))

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