fdetsch / MODIS

Download and processing framework for MODIS imagery. The package provides automated access to the global online data archives LP DAAC, LAADS and NSIDC as well as processing capabilities such as file conversion, mosaicking, subsetting and time series.
Other
58 stars 27 forks source link

gdal_utils warp: an error occured #98

Open mlampros opened 4 years ago

mlampros commented 4 years ago

@MatMatt, @fdetsch this issue is another case where the runGdal() function throws the error

Error in sf::gdal_utils(util = "warp", source = gdalSDS, destination = ofile,  : 
       gdal_utils warp: an error occured

but it's not related to PR96

It seems that although SDS can have a length > 1 it is hard coded to process only the first item SDS[[1]] (here, here, here, here and here) and overwrite any previous saved files. For instance, if SDS is of length 2 and is passed to sf::gdal_utils() then gdalSDS is also of length 2 and this causes the error.

Normally, the 'source' parameter of the 'sf::gdal_utils' function can take more than 1 files however this is not the case. I think due to the fact that only the first item of SDS is processed then it might be proper to use either the first index in gdalSDS or the last index (if it's the most updated or if it represents a different orbit). Although, I think it would be wise to compute the file size of all available products and pick the one with the highest coverage (bigger size).

                    sf::gdal_utils(
                      util = "warp"
                      , source = gdalSDS[1]
                      # , source = gdalSDS[length(gdalSDS)]

at least this works in my case.

Another option would be to add a for-loop and iterate over all available files,

            for (sds_file in seq_along(SDS)) {

but I don't know if the default behavior is to overwrite previous files in case of multiple files.

This issue might be related with issue 93