Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple rasters which overlap eachother geospatially but do not completely occupy the same space. I can combine them with gdalwarp like:

gdalwarp -s_srs EPSG:4326 *.tif larger_output.tif

In this method gdalwarp uses the order of the input files to determine which pixel ends up in the final image in the case that two pixels occupy the same location in the x,y plane.

Is it possible to tell gdalwarp to use the max(intensity(x,y)) of a given pixel that overlaps another pixel in the input as a means of determining which one ends up in the final image?

I presume the code behind gdalwarp works on the images sequentially or at least in separate threads and then combines them one at a time into a final raster? This addition might be as simple as an if statement that before replacing a given pixel in the final raster would compare intensities (if there were already a value there).

Does something like this already exist or should I get into the code to try something out?

share|improve this question
Kinda tricky. I think the use of a more "full-fledged" GIS software (e.g. GRASS/SAGA/QGIS/etc.) should make things easier for you.. – user8723 Nov 18 '12 at 5:08
up vote 1 down vote accepted

I started digging into the gdal source found where I could make the changes but figured that I might not want to do it this way after all. What I decided to do instead (but have yet to do) was:

Iterate through the images, grabbing the bbox of each, then based on each bbox make groups of non-overlapping images. Then use gdalwarp to combine each non-overlapping set (since they dont overlap it doesnt matter what order you send them to gdalwarp) into a single image as above. Whilst looking at each bbox above I calculate a bbox that is the extrema of all bboxes, so that when I do the gdalwarp of each non-overlapping set, I end up with images for each set that are the same dimensions and have the same origin. Finally to combine them taking the maximum intensity at each pixel I use imagemagick's composite with the -compose lighten option. I think I might even be able to forgo making all the images the same size with the same origin if I use imagemagick's -geometry option to specify an offset.

share|improve this answer

Your Answer


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.