[gdal-dev] Preserve Source Raster Resolution When Merging

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Thu Aug 25 06:11:39 PDT 2016


Sam Wilson wrote:

> Hi,

> I'm attempting to merge (or maybe the proper term is mosaic) overlapping raster datasets of varying resolutions. I'd like to have the higher  resolution datasets override the lower resolution datasets where available.

> I've been able to get close using various methods i.e. gdal_merge.py or by constructing a VRT using gdalbuildvrt and providing the input file list.

> However, both of those methods don't seem to be ideal, unless I'm mistaken, because I'd prefer to preserve the native resolution of all datasets being merged.

> For example, when using gdal_merge, you can provide a single pixel size, which I think makes the entire merged raster at that resolution. Thus, I end up gaining resolution where I don't want it and losing resolution where I do want it. The same goes using the gdalbuildvrt method using the -resolution argument.

> The end goal is to have a single raster containing all the input rasters at their native resolutions.  I've done a lot of searching around online and it appears that this can be achieved using ArcGIS tools.  However, I'm wondering if there are any workarounds to achieve that other than using ArcGIS.  For example, is their a modified version of gdal_merge.py that keeps the source rasters at their native resolutions when merging?

> Thanks for any help!

Hi Sam,

Unfortunately you can't do that. From https://en.wikipedia.org/wiki/Raster_graphics
"In computer graphics, a raster graphics image is a dot matrix data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium. Raster images are stored in image files with varying formats."

It is hard to believe that ArcGIS could write raster files with variable pixel size either. I rather believe that it keeps the native resolution images somewhere in files or in the database and mosaics, resamples, and renders them on-the-fly. Something that you can simply demonstrate by opening your native images into the same QGIS project. But because of your online search work you must have some links to share with us.

BTW. if you select the best resolution of all the native images for the mosaic you will not lose anything, except disk space.

-Jukka Rahkonen-

> Cheers,
> Sam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160825/0ada72d9/attachment-0001.html>


More information about the gdal-dev mailing list