chrisvwn / Rnightlights

R package to extract data from satellite nightlights.
GNU General Public License v3.0
47 stars 14 forks source link

Replicating vignette with downloadMethod = "aria" #64

Closed sciabolazza closed 3 years ago

sciabolazza commented 3 years ago

When including pkgOptions to enhance performance, Rnightlights is not able to reproduce the example contained in the vignette.

I am wondering whether there is some issue on my side, or something is off when setting downloadMethod = "aria".

I have installed aria2c using the R package sen2r (sen2r::install_aria2()) The GDAL version in use on my computer is the 2.2.4 (checked with sen2r:: check_gdal())

I ran:

pkgOptions(downloadMethod = "aria", cropMaskMethod = "gdal", extractMethod = "gdal", deleteTiles = FALSE) pkgOptions(extractMethod="rast") pkgOptions(numThreads = 4) ctry <- "KEN" #replace to run for any other country highestAdmLevelStats <- getCtryNlData(ctryCode = ctry, admLevel = "highest", nlType = "VIIRS.M", nlPeriods = nlRange("201401", "201412","VIIRS.M"), nlStats = list("sum",na.rm=TRUE), ignoreMissing=FALSE)

The output returned was:

Processing missing data: KEN:VIIRS.M:VCMCFG:201401:sum, VIIRS.M:VCMCFG:201402:sum, VIIRS.M:VCMCFG:201403:sum, VIIRS.M:VCMCFG:201404:sum, VIIRS.M:VCMCFG:201405:sum, VIIRS.M:VCMCFG:201406:sum, VIIRS.M:VCMCFG:201407:sum, VIIRS.M:VCMCFG:201408:sum, VIIRS.M:VCMCFG:201409:sum, VIIRS.M:VCMCFG:201410:sum, VIIRS.M:VCMCFG:201411:sum, VIIRS.M:VCMCFG:201412:sum. This may take a while. Note: Set 'ignoreMissing=TRUE' to return only data found or 'ignoreMissing=NULL' to return NULL if not all the data is found 2020-10-01 12:48:31: **** START PROCESSING: ctryCodes=KEN, admLevels=list(KEN = "gadm36_KEN_1"), nlTypes=VIIRS.M, configNames=VCMCFG, multiTileStrategy=all, multiTileMergeFun=mean, removeGasFlares=TRUE, nlPeriods=c("201401", "201402", "201403", "201404", "201405", "201406", "201407", "201408", "201409", "201410", "201411", "201412"), nlStats=list(list("sum", na.rm = TRUE)), custPolyPath=NULL, gadmVersion=3.6, gadmPolyType=shpZip, downloadMethod=aria, cropMaskMethod=gdal, extractMethod=rast**** 2020-10-01 12:48:31: Downloading country polygons ... | | 0%2020-10-01 12:48:31: Downloading polygon: KEN 2020-10-01 12:48:31: Downloading ctry poly: KEN 2020-10-01 12:48:31: Downloading ctry shpZip: KEN 2020-10-01 12:48:31: Polygon dir for KEN:3.6 already exists |=======================================================================================| 100% 2020-10-01 12:48:31: Downloading country polygons ... DONE 2020-10-01 12:48:31: **** PROCESSING nlType:VIIRS.M | configName: VCMCFG | nlPeriod:201401**** 2020-10-01 12:48:31: Checking tiles required for VIIRS.M 201401 2020-10-01 12:48:31: KEN: Stats missing. Adding tiles 2020-10-01 12:48:33: numTiles: 2, Required tiles: 75N060W,00N060W 2020-10-01 12:48:33: Downloading tile: 2014012 2020-10-01 12:48:34: An error occurred downloading 2020-10-01 12:48:34: Downloading tile: 2014015 2020-10-01 12:48:34: Something went wrong with the tile downloads. Aborting ... 2020-10-01 12:48:34: **** COMPLETED PROCESSING :ctryCodes=KEN, admLevels=gadm36_KEN_1, nlTypes=VIIRS.M, configNames=VCMCFG, multiTileStrategy=all, multiTileMergeFun=mean, removeGasFlares=TRUE, nlPeriods=c("201401", "201402", "201403", "201404", "201405", "201406", "201407", "201408", "201409", "201410", "201411", "201412"), nlStats=list(list("sum", na.rm = TRUE)), custPolyPath=NULL, gadmVersion=3.6, gadmPolyType=shpZip, downloadMethod=aria, cropMaskMethod=gdal, extractMethod=rast**** Error in data.table::fread(getCtryNlDataFnamePath(ctryCode = ctryCode, : File 'C:/Users/Valerio/Documents/.Rnightlights/data/NL_DATA_KEN_ADM1_GADM-3.6-SHPZIP.csv' does not exist or is non-readable. getwd()=='C:/Users/Valerio/Documents/lybia_2.0' In addition: Warning messages: 1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 3: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 4: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 5: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 6: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 7: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved 8: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded datum WGS_1984 in CRS definition, but +towgs84= values preserved

chrisvwn commented 3 years ago

For the pkgOption(downloadMethod="aria") to work aria2c must be in the path and accessible from the commandline. Please see if you can run aria2c from the command prompt. If not, add its install location to the PATH environment variable.

sciabolazza commented 3 years ago

I am not sure I understand what you suggest in order to specify what is the directory that R should use to access aria.

Should I install aria in the directory folder declared with the function setwd? Is there an alternative way to do this? For instance, I have looked at Rnightlights::pkgOptions but it seems this is not the way to go.

It seems in any case that this issue is not directly related to Rnightlights. However, if you think that other people might benefit from this so that they can use Rnightlights with aria, would you mind to suggest a way to proceed?

chrisvwn commented 3 years ago

Hi,

Yes, the PATH environment variable is to enable your operating system to know where aria2 is installed. Rnightlights depends on the operating system knowing where aria2 is.

If you're using windows, you could try using the instructions here to add aria2c to the path: https://www.studytonight.com/post/how-to-set-path-environment-variable

You may need to specify the folder where you want sen2r to install aria2 so that it is a fixed path that you can use in the PATH var.

chrisvwn commented 3 years ago

Closing this issue. If you are still facing it please reopen.