chrisvwn / Rnightlights

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

Unable to find an inherited method for function ‘mask’ #74

Closed lrose1 closed 3 years ago

lrose1 commented 3 years ago

Hello, I am getting an error that I cannot figure out. The error message seems quite vague:

Input: `library(Rnightlights) pkgOptions(downloadMethod = "aria", cropMaskMethod = "gdal", extractMethod = "gdal", deleteTiles = TRUE)

ctry <- "HUN" #replace to run for any other country

magyarorsag <- getCtryNlData(ctryCode = ctry, admLevel = "lowest", nlType = "VIIRS.M", nlPeriods = nlRange("201401", "201402"), nlStats = list("sum",na.rm=TRUE), ignoreMissing=FALSE) Output, truncated (... info on downloading here ...)

Status Legend: (OK):download completed. 2021-05-12 16:12:14: Extracting /Users/myname/.Rnightlights/tiles/SVDNB_npp_20160101-20161231_75N060W_v10_c201807311200.tgz 2021-05-12 16:12:14: Getting list of files in /Users/myname/.Rnightlights/tiles/SVDNB_npp_20160101-20161231_75N060W_v10_c201807311200.tgz 2021-05-12 16:15:27: Extracting ./SVDNB_npp_20160101-20161231_75N060W_vcm-orm-ntl_v10_c201807311200.avg_rade9.tif 2021-05-12 16:19:46: RGF: Cropping the raster tiles 2021-05-12 16:19:46: RGF: Cropping mask tile = 75N060W 2021-05-12 16:19:46: RGF: Masking the raster 2021-05-12 16:19:46: RGF: Crop and mask using gdalwarp ... 2021-05-12 16:19:46: RGF: Writing merged raster to disk for gdalwarp masking 2021-05-12 16:19:47: RGF: gdalwarp masking to VRT 2021-05-12 16:19:47: RGF: gdal_translate converting VRT to TIFF 2021-05-12 16:19:47: RGF: Deleting the component rasters 2021-05-12 16:19:47: RGF: Crop and mask using gdalwarp ... DONE Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘mask’ for signature ‘"NULL", "RasterLayer"’`

chrisvwn commented 3 years ago

Hi,

This may be due to some changes that have happened in other packages especially around the gdal-based implementation. Let me run the same commandline and see what might be happening. Meanwhile, you can try to run it without gdal by changing the pkgOptions. So either don't set cropMaskMethod and extractMethod so they use the default (rast) or instead of gdal set them to "rast".

cropMaskMethod = "rast", extractMethod = "rast" 
chrisvwn commented 3 years ago

Closing this issue. Do reopen if the resolution given did not work.