r-spatial/stars

abind Error when converting a .tif raster data object to an sf object using st_xy2sfc() in R

fgoerlich opened this issue · 3 comments

Hi,
I get this error

Error in abind(x, along = length(dim(x)) + 1) : 
  along must be between 0 and 2

when converting an star object into a point sfc using st_xy2sfc() in R:

read_stars("NDSM-Edificacion-REGCAN95-H28-1083-COB1.tif") |> st_xy2sfc(as_points = TRUE, na.rm = TRUE)

Other similiar files work properly.
Thanks a lot!

NDSM-Edificacion-REGCAN95-H28-1083-COB1.zip

edzer commented
read_stars("NDSM-Edificacion-REGCAN95-H28-1083-COB1.tif") |> st_as_stars() |> st_xy2sfc(as_points = TRUE, na.rm = TRUE)

I agree the error message is far from helpful, let's leave this issue open.

You are right!
But If I read the file in terra I get the same error

terra::rast("NDSM-Edificacion-REGCAN95-H28-1083-COB1.tif") |> st_as_stars() |> st_xy2sfc(as_points = TRUE, na.rm = TRUE)
Error in abind(x, along = length(dim(x)) + 1) : 
  along must be between 0 and 2
edzer commented

In that case, you need to specify proxy = FALSE in st_as_stars().