spatialstatisticsupna / RGISTools

Tools for Downloading, Customizing, and Processing Time Series of Satellite Images from Landsat, MODIS, and Sentinel
GNU General Public License v3.0
51 stars 15 forks source link

Cannot download Landsat8 images through RGISTools R package #8

Open caio-valente14 opened 3 years ago

caio-valente14 commented 3 years ago

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 commented 3 years ago

I tried to run a simple debug with lsDownload() and it seems that when the function calls a nested function named lsEarthExplorerDownload(), but since I'm a beginner in R, I couldn't find more details. This package has some great functions, and I aim to use them in my project. I hope you can fix the problem. Thanks a lot!

michielvandijk commented 3 years ago

I have exactly the same problem when trying to download Landsat 7 output. I agree with the others, this is an excellent package as it offers the possibility to easily download and process satellite data, which is not offered by any other R packages currently available. I would be very grateful if the authors can fix this issue in the very near future.

caio-valente14 commented 3 years ago

Another way of dealing with satelite images in R. There is a package called rgee, which connects an R session to Google Earth Engine API.

unai-perez commented 3 years ago

Sorry for the errors with this package. The last few months the API that RGISTools uses to download images has changed a lot. Because of that, the package is not able to download the landsat images.The last months we have been working on a redefinition of the package. The new package is called rsat and can download landsat imagery. The package is not on CRAN but you can download it from GitHub.You can start using the package by reading the 4 vignettes it includes. Use this command to install the package from github:

devtools::install_github("spatialstatisticsupna/rsat", build_vignettes=TRUE)
browseVignettes("rsat")
bholtdwyer commented 1 year ago

Sorry, but shouldn't the page say somewhere that this has been superseded by rsat, if that's the case? Also, rsat's GitHub page appears to not have any "issues' tab, which is not helpful as it has multiple...issues! The vignettes don't build properly, and on loading it tries to load a package called "dplur" (looks like a typo to me)