When I try to convert a .tif
raster data object to an sf
object using st_as_sf()
in R
, I get the following error:
Error in abind(x, along = length(dim(x)) + 1) : along must be between 0 and 2
Does anyone know how to solve this?
The .tif
data for which to reproduce this I got from https://sedac.ciesin.columbia.edu/data/set/gpw-v4-data-quality-indicators-rev11/data-download.
The error occurs both for the Data Context and Mean Administrative Unit Area data. Choose GeoTiff
and 30 sec (1 km) resolution
.
The reprex R
code is then (for the Data Context data, for example):
library(stars)
# Load data
gpw_raw <- read_stars("gpw_v4_data_quality_indicators_rev11_context_30_sec.tif")
# Attemt to convert .tif into sf object
gpw <- st_as_sf(gpw_raw)
One resource I used, which in the end did not allow me to solve the issue, is: https://r-spatial.github.io/stars/articles/stars5.html#vectorizing-a-raster-object-to-an-sf-object
Thanks for your help!