I have a series of GTiff images that I am trying to merge into a single larger extent. 6 small tiles need to be combined to generate my larger extent. My original 6 tiles have values which range from 0 to 255.
For example:
> tiff.list[[1]]
class : RasterLayer
dimensions : 1200, 1200, 1440000 (nrow, ncol, ncell)
resolution : 926.6254, 926.6254 (x, y)
extent : -10007555, -8895604, 2223901, 3335852 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
data source : D:\Scratch\Data\MOD15A2.A2016153.h09v06.005.2016166083754.tif
names : MOD15A2.A2016153.h09v06.005.2016166083754
values : 0, 255 (min, max)
However, when merging the tiles using the code detailed here, I get a new image file and the values have changed:
> xx
class : RasterLayer
dimensions : 2400, 3600, 8640000 (nrow, ncol, ncell)
resolution : 926.6254, 926.6254 (x, y)
extent : -10007555, -6671703, 1111951, 3335852 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
data source : D:\Scratch\Modis\A2016161.tif
names : A2016161
values : 0, 25 (min, max)
Does anyone know why this is happening? I've tried changing the file format and dataType ('INT1U') but it keeps happening. It's important the values don't change from 0 to 255 as the original data comes from NASAs MODIS satellite and certain values (i.e. 248-255) have specific fill values associated with them (for example, land cover assigned as water or snow). This change from a max value of 255 to 25 is removing important information from the original files.
Any assistance provided would be most welcome.
mergeormosaicwill change the values of MODIS rasters (it appears to usually be by 2 orders of magnitude). I've found that usingmosaic_rasters()fromgdalutilsproduces the desired results see the final answer to this question for more info: stackoverflow.com/questions/15876591/… - admccurdy