Error in readRDS(s2tiles_rds) : unknown input format while using `sen2r` r package

121 views Asked by At

I was trying to download Sentinel 2 image using sen2r() from the command line as provided in the Vignettes using the following codes

library(tidyverse)
library(sen2r)
library(sf)

#Downloading data from DIVA GIS website
get_india_map <- function(cong=113) {
  tmp_file <- tempfile()
  tmp_dir  <- tempdir()
  zp <- sprintf("http://biogeo.ucdavis.edu/data/diva/adm/IND_adm.zip",cong)
  download.file(zp, tmp_file)
  unzip(zipfile = tmp_file, exdir = tmp_dir)
  fpath <- paste(tmp_dir)
  st_read(fpath, layer = "IND_adm2")
}

ind <- get_india_map(114)

#To view the attributes & first 3 attribute values of the data
ind[1:3,]

#Selecting specific district
Delhi <- ind %>% 
  filter(NAME_1=="Delhi") %>%
  mutate(DISTRICT = as.character(NAME_2)) %>%
  select(DISTRICT)

plot(Delhi)

# Set paths
out_dir_1  <- tempfile(pattern = "sen2r_out_1_") # output folder
safe_dir <- tempfile(pattern = "sen2r_safe_")  # folder to store downloaded SAFE

out_paths_1 <- sen2r(
  gui = FALSE,
  step_atmcorr = "l2a",
  extent = Delhi,
  timewindow = c(as.Date("2020-11-13"), as.Date("2020-11-25")),
  list_prods = c("BOA","SCL"),
  list_indices = c("NDVI","MSAVI2"),
  list_rgb = c("RGB432B"),
  mask_type = "cloud_and_shadow",
  max_mask = 10, 
  path_l2a = safe_dir,
  path_out = out_dir_1
)

But it returns me following error

Error in readRDS(s2tiles_rds) : unknown input format

How to solve this issue?

0

There are 0 answers