Hi everyone,

I have a large geoTiff raster file that does not fit in memory (if I do read_stars(file_path) I get "Error: cannot allocate vector of size 12.7 Gb"). How can I read a spatial subset of that file.

The example below works with a toy example but not with the actual large dataset.

library(stars)
library(sf)

tif = system.file("tif/L7_ETMs.tif", package = "stars")
window <- read_stars(tif) %>%
    st_bbox() %>%
    st_as_sfc() %>%
    st_buffer(-2000) %>%
    st_bbox()

tif_sub <- read_stars(tif, proxy = TRUE) %>%
    st_crop(window)

plot(tif_sub)

I get the following error:

Error in x[[i]][1:-21561856, 1:146, , drop = FALSE] :
  only 0's may be mixed with negative subscripts

Kind regards,
Loïc

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to