RGISTools icon indicating copy to clipboard operation
RGISTools copied to clipboard

Cannot download Landsat8 images through RGISTools R package

Open caio-valente14 opened this issue 4 years ago • 5 comments

I've been having a hard time trying to automate some Landsat 8 image download and processing for my project.


At first, I tried to use getSpatialData package to do what I need from R, but it seems the authors aren't maintaining and supporting the library recently.


Now, I'm trying to acomplish my goals by using RGISTools package, but I'm reading the article the authors wrote about the package and testing in real time here in Rstudio and when I try to run some functions like lsDownload(), and it keeps returning an error:


Downloading the images in: C:/PROJETOS_PRINCIPAIS2/AUTOMATE_SATELITE_IMAGE/RGISTools/Teste/landsat8/downloads/Landsat8/raw

Starting Landsat level 1 download process...

Error in charToRaw(enc2utf8(val)) :

  argument must be a character vector of length 1

Here is my code for you to take a look if I'm missing something:

##### Import libraries #####

library(raster)

library(sp)

library(sf)

library(RGISTools)

##### Set the working directory #####

scriptWD <- 'C:/PROJETOS_PRINCIPAIS2/AUTOMATE_SATELITE_IMAGE/RGISTools/Teste'

setwd(scriptWD)

##### Import area of interest #####

hortoMG <- st_read('mogiGuacu.shp')

##### Searching for images #####

search <- lsSearch(AppRoot = scriptWD,

                    product = 'LANDSAT_8_C1',

                    dates = as.Date('2020-07-01') + seq(0, 15, 1),

                    region = hortoMG,

                    cloudCover = c(0, 80),

                    username = '*****',

                    password = '*****')


##### Search Preview #####

lsPreview(searchres = search)

##### Create the wd for landsat images downloads #####

wdLandsat <- file.path(scriptWD, 'landsat8')

wdLandsatDownload <- file.path(wdLandsat, 'downloads')

##### Baixando imagens #####

testDownload <- lsDownload(searchres = search,

                    AppRoot = wdLandsatDownload,

                    lvl = 1,

                    product = 'LANDSAT_8_C1',

                    extract.tif = TRUE,

                    username = '*****',

                    password = '*****',

                    nattempts = 5)

caio-valente14 avatar Feb 04 '21 11:02 caio-valente14