chrisvwn / Rnightlights

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

Cannot open data source in getCtryNlData function #24

Closed nreguera closed 5 years ago

nreguera commented 5 years ago

Hi Chris,

I am trying to reproduce the example in your blog, but I got an error message:

2019-02-27 10:30:08: NlRange autodetected nlType: VIIRS.M Error in rgdal::ogrListLayers(dsn = path.expand(path = getPolyFnamePath(ctryCode = ctryCodes, : Cannot open data source

I attach you a screenshot where you can see the few lines I input when got the message.

Thanks.

screenshot

chrisvwn commented 5 years ago

Hi,

This sounds like a possible download error.

Could you delete all files and folder with "KEN" in the name in the polygons folder in your data directory?

Then rerun for the download of polygons to repeat.

nreguera commented 5 years ago

So, this is what I did:

screenshot

nreguera commented 5 years ago

Btw, after the two previous loads (MMR and KEN) in the data folder only appears one file (NL_STRUCT_MMR_GADM-3.6)

chrisvwn commented 5 years ago

This looks like the problem related to downloading the tile: screenshot from 2019-02-27 13-56-54

This is the kind of output we are expecting: screenshot from 2019-02-27 14-01-27

Is it possible the downloads are being interrupted?

nreguera commented 5 years ago

Mmm I deleted all the files and tried again, but I still get the same messages (the ones you pointed out).

I am in a public wireless hotspot but the connection is quite good...

Should I remove all the files related to the countries and try again?

chrisvwn commented 5 years ago

Hmm. Could they be restricting large downloads? Try downloading the tile directly e.g. try this https://data.ngdc.noaa.gov/instruments/remote-sensing/passive/spectrometers-radiometers/imaging/viirs/dnb_composites/v10//201204/vcmcfg/SVDNB_npp_20120401-20120430_75N060W_vcmcfg_v10_c201605121456.tgz

nreguera commented 5 years ago

Don´t thing so, I have downloaded virtual machines of 3/4 Gbs...

I have reset and deleted all data, even in R session, and now it looks it´s downloading properly, despite a bit slow. Wait until it finish and I will let you know.

screenshot

chrisvwn commented 5 years ago

Okay. Yes. This looks positive. If the download completes fine it should run successfully.

If you want faster downloads you can experiment with the aria2 option by installing https://aria2.github.io/ and setting pkgOptions(downloadMethod="aria")

nreguera commented 5 years ago

Hi Chris,

Yesterday I had to interrupt the download because I needed to leave, and now I am getting the same problems. What should I clean to restart the download?

chrisvwn commented 5 years ago

Hi Natxo,

Delete the .tif and/or .tgz files corresponding to the interrupted download in the tiles folder.

nreguera commented 5 years ago

Ok, it was working until the internet connection fell down, so I need to restart right? It would be nice to be able to continue the download where it was cut...

chrisvwn commented 5 years ago

Noted. The aria option has this capability but it is a bit more complex when using the default R downloader.

nreguera commented 5 years ago

I am going to try with aria. I just downloaded it, and I am wondering if I need to install it or set it up to use it with Rnightlights package...

chrisvwn commented 5 years ago

Just install it and ensure you can access it globally by running aria2c from the commandline. (If it is not accessible after install, you can add the installation folder to the PATH environment variable). Then run pkgOptions(downloadMethod='aria') before running getCtryNlData.

nreguera commented 5 years ago

Thanks for your support Chris, I think we can close this issue and move on.