chrisvwn / Rnightlights

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

Not managing to get data with custom polygon #16

Closed giacfalk closed 5 years ago

giacfalk commented 5 years ago

Using the GitHub development version of Rnightlights, I am trying to work with a custom shapefile with the following code:

getnldata_VIIRS<-getCtryNlData(custPolyPath = shapefile_zip, nlType = "VIIRS.M", nlPeriods = nlRange("201301", "201712"), nlStats = "sum", ignoreMissing=TRUE)

But I get the following error message

Error in getCtryNlData(custPolyPath = shapefile_zip, nlType = "VIIRS.M", nlPeriods = nlRange("201301", : 2018-09-25 15:56:26: Invalid ctryCode

I am aware that I am missing the arguments, ctryCode and admLevel, but what values should I put considering my shapefile is not a country?

chrisvwn commented 5 years ago

Could you try setting ctryCode to the country where the polygon is from (or any country really). custPolyPath is still in development and there may still be some code that requires ctryCode. Should be fixed once the dev version stabilizes.

For admLevel, you could try running searchAdmLevel() and this should list the detected/named admLevels if the shapefile has already been imported. Note admLevels are, currently, just the layer names with an index prefix and not the names in the shapefile.

You can also see the names of the layers in the output the first time getCtryNlData runs as it imports the shapefile.

giacfalk commented 5 years ago

Ok, in the future it would be great to be able to input any custom shapefile (e.g. a city, or a metropolitan area) unlinked from the concept of administrative level. But thanks for your help and developing this great package, anyhow!

chrisvwn commented 5 years ago

Thanks @giacfalk . Indeed this is the goal. It might just take a bit of time to get there.