sf icon indicating copy to clipboard operation
sf copied to clipboard

St_union in data frame with no data, replacement has 1 row, data has 0

Open latot opened this issue 1 year ago • 0 comments

Hi, this is no the first time with this type of bug, in this case, if we do union with an empty dataframe we get the error, this is just as an easy example, when this happens? for example filtering with intersects or any other operation of that kind.

> library(sf)
Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
> p1 <- st_sfc(c(st_point(runif(2)))) %>% st_as_sf()
p2 <- p1[0,]

sf::st_union(p1, p2)
Error in `[[<-.data.frame`(`*tmp*`, attr(x, "sf_column"), value = list( : 
  replacement has 1 row, data has 0
> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Gentoo Linux

Matrix products: default
BLAS:   /usr/lib64/libblas.so.3.10.0
LAPACK: /usr/lib64/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=es_CL.utf8       LC_NUMERIC=C             
 [3] LC_TIME=es_CL.utf8        LC_COLLATE=es_CL.utf8    
 [5] LC_MONETARY=es_CL.utf8    LC_MESSAGES=es_CL.utf8   
 [7] LC_PAPER=es_CL.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=es_CL.utf8 LC_IDENTIFICATION=C      

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

other attached packages:
[1] sf_1.0-8

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9         magrittr_2.0.3     units_0.8-0        tidyselect_1.1.2  
 [5] R6_2.5.1           rlang_1.0.4        fansi_1.0.3        dplyr_1.0.9       
 [9] tools_4.2.1        grid_4.2.1         KernSmooth_2.23-20 utf8_1.2.2        
[13] cli_3.3.0.9000     e1071_1.7-11       DBI_1.1.3          ellipsis_0.3.2    
[17] class_7.3-20       assertthat_0.2.1   tibble_3.1.7       lifecycle_1.0.1   
[21] purrr_0.3.4        vctrs_0.4.1        glue_1.6.2         proxy_0.4-27      
[25] compiler_4.2.1     pillar_1.8.0       generics_0.1.3     classInt_0.4-7    
[29] pkgconfig_2.0.3

Thx!

latot avatar Jul 26 '22 15:07 latot