chrisvwn / Rnightlights

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

Error in producing data file #57

Closed marie-lay closed 4 years ago

marie-lay commented 4 years ago

Hello,

I'd like to start by thanking you for that super efficient package! I hope you are doing ok in these trying times.

Seeing that the package is off CRAN for now, I tried manually installing it like you advised.

#added package 'dplyr' install.packages(c('cleangeo', 'curl', 'data.table', 'doSNOW', 'plyr', 'ff', 'ffbase', 'foreach', 'lubridate', 'raster', 'readr', 'reshape2', 'rgdal', 'rgeos', 'R.utils', 'rvest', 'rworldmap', 'settings', 'snow', 'sp', 'stringr', 'xml2','dplryr'))

packageurl <- "https://cran.r-project.org/src/contrib/Archive/Rnightlights/Rnightlights_0.2.4.tar.gz" install.packages(packageurl, repos=NULL, type="source")

#manually installed package library(dplyr) library(gdalUtils)

``#error: package 'Rnightlights' is not available (for R version 3.6.3)

on https://github.com/chrisvwn/Rnightlights/issues/44, creator says it's "down for review", download manually

install.packages("Rnightlights")``

library(Rnightlights)

The package is extracted and works.

Then, my objective is to extract on R studio (3.6.3) OLS satellite nightlights (NL) data for Lebanon in 2005 for the most local administrative level.

ctry <- "LBN" #replace to run for any other country NL <- getCtryNlData(ctryCode = ctry, "admLevels=gadm36_LBN_3", nlType = "OLS.Y", nlPeriods = "2005", nlStats = list("sum",na.rm=TRUE), removeGasFlares = FALSE, ignoreMissing=FALSE)

When I execute the above, everything downloads normally, the file creation gets to 100%, then I get this error and no data output: task 8 failed - "'names' attribute [5] must be the same length as the vector [4]"

I don't know what names it is referring to. PS: I tried with a different broader administrative level and it worked (admLevel = "highest"), but I need more locally precise data...

I remain available for more info. Thanks for your time. Best, Marie

chrisvwn commented 4 years ago

Hi @marie-lay Looking into this. I suspect that this is a problem related to the shapefile for LBN.

marie-lay commented 4 years ago

Hello, yeah makes sense! I appreciate it. Best, Marie

chrisvwn commented 4 years ago

Finally, found the problem. There is a bug which was causing some internal structures to have the wrong dimensions hence the name length mismatch error.

I have fixed this in the github version and you can try that out. Note, there are some major changes which means you might have to recalculate any stats you already had. There may also be some new bugs as this is still in development but I was able to run your code successfully.

marie-lay commented 4 years ago

I reinstalled the package, and I was able to run the code as well. Thank you very much for your work! Take care.