hypertidy/silicate

new tibble

Closed this issue · 2 comments

Symptom (tibble_2.99.99.9014):

tibble::as_tibble(silicate::minimal_mesh)

Error: All columns in a tibble must be vectors:
* Column `geom` is sfc_MULTIPOLYGON
Run `rlang::last_error()` to see where the error occurred.

sf defines vec_proxy.sfc which is a fix:

vec_proxy.sfc <- function(x, ...) {
 x
}
tibble::as_tibble(silicate::minimal_mesh)
# A tibble: 2 x 2
      a geom                                                                                    
  <int> <s_MULTIP>                                                                              
1     1 0.00, 0.00, 0.75, 1.00, 0.50, 0.80, 0.69, 0.00, 0.00, 1.00, 1.00, 0.80, 0.70, 0.60, 0.0…
2     2 0.69, 0.80, 1.10, 1.23, 0.69, 0.00, 0.60, 0.63, 0.30, 0.00      

or we could

m <- tibble::as_tibble(silicate::minimal_mesh)
g <- m$geom
# rm(vec_proxy.sf)
# m$geom <- g
# Error: `x` must be a vector, not a `sfc_MULTIPOLYGON/sfc` object.
# Run `rlang::last_error()` to see where the error occurred.


class(g) <- c("sfc_MULTIPOLYGON", "sfc", "list")
m$geom <- g
m
# A tibble: 2 x 2
      a geom      
  <int> <s_MULTIP>
1     1 <XY>      
2     2 <XY>      
sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
 [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C             
 [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] silicate_0.1.5.9001

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0          tidyr_0.8.2         crayon_1.3.4        dplyr_0.8.0.1      
 [5] assertthat_0.2.1    R6_2.4.0            magrittr_1.5        pillar_1.4.3       
 [9] rlang_0.4.5         rstudioapi_0.9.0    vctrs_0.2.99.9006   tools_3.5.3        
[13] glue_1.3.1          purrr_0.3.0         compiler_3.5.3      pkgconfig_2.0.3    
[17] gibble_0.1.2.9005   tidyselect_0.2.5    tibble_2.99.99.9014

Another problem, this is ok with tibble 2.1.3, but here it breaks and the segments are degenerate (see with plot(SC0(x)))

x <- TRI(minimal_mesh)

SC0(x)
# Warning messages:
# 1: Element 4 must be length 36, not 12 
# 2: Element 5 must be length 36, not 12 
# 3: Element 4 must be length 36, not 12 
# 4: Element 5 must be length 36, not 12 

Seems to only be a problem with SC0(TRI(x)) and SC0(TRI0(x))