Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to merge together 20 32 bit tiff. For that I tried ArcGis but it keeps crashing (the individual tiff are about 1GB). I need a finale Tiff in order to run some analysis and I figured that having 20 different file would be messy for the user who is going to do the analysis.

I found a mosaic tool in the raster package in R but I can't really figure out how to use it. My first idea was to create a list of the tiff and then ask the mosaic tool to process it but it gives me error.

Error in function (classes, fdef, mtable) : unable to find an inherited method for function "mosaic", for signature "list", "missing"

I found this script online but it seems that many function doesn't work anymore

require(raster)
input.rasters <- lapply(list.files(pattern="^TmB50.*[.]tif$"), raster)
full.extent <- unionExtent(input.rasters)
bounding.raster <- raster(full.extent,crs=projection(input.rasters[[1]]))
res(bounding.raster) <- res(input.rasters[[5]])
resampled.rasters <- lapply(input.rasters, function(input.raster) {
target.raster <- crop(bounding.raster, input.raster)
resample(input.raster, target.raster, method="bilinear")
})
raster.mosaic <- mosaic(resampled.rasters, fun=max)

source http://www.nceas.ucsb.edu/scicomp/usecases/createrasterimagemosaic

Any idea how I could do that?

share|improve this question
    
my advise is: don't even try to do it in R ! you can't mosaic 20 files with 1Gb each in R, without facing 999999999 diferent problems, –  A.R Jan 17 '13 at 19:58
add comment

1 Answer

I would advise against image processing with R. Rather, I would revisit mosaicing your imagery with ArcGIS. I used the following model recently to mosaic approximately 40 1m CIR raster images into a 25 GB mosaic (shown below). ArcGIS is definitely capable of large scale processing if you do it correctly. A few ideas:

  • Make sure to set the raster storage environment for compression, building pyramids and calculating statistics.
  • You'll likely have better success using Mosaic To New Raster rather than Mosaic (Data Management).
  • Run 64 bit background geoprocessing for ArcGIS 10.1 SP1 if you are still encountering issues, available here.

I certainly do not want to dissuade you from raster processing with R, however, I think you will find a host of other issues when forcing R to process big raster data.

enter image description here

enter image description here

share|improve this answer
    
Thank you for the answer, I give another try then. What do you mean by Make sure to set the raster storage environment for compression, building pyramids and calculating statistics. My raster doesnt have the same resolution should I fix that beforehand? –  user10918 Jan 17 '13 at 20:08
    
Right click on the Mosaic To New Raster tool in the model, select Properties and place a check next to Raster Storage box. When you check that box, by default full pyramids will be built, statistics will be calculated and LZ77 compression will be implemented. These are primarily used so that you can efficiently view the mosaic after it is created. What is your raster resolution now? –  Aaron Jan 17 '13 at 20:18
    
The resolution is about 0.5m/pixel –  user10918 Jan 17 '13 at 21:19
    
@user10918 I should also point out that the inputs must have the same number of bands and bit depth for the tool to work. –  Aaron May 16 '13 at 17:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.