I am hoping to come up with a script that would allow me to mosaic imagery into a polygon tile grid. My hopes is to do this with gdal or QGIS. I am wondering if anyone knows of an existing script, before I start. My first thoughts was to use gdal_merge, but I do not see a variable for using a polygon (shapefile) as the boundary. gdal_merge does have the -ul_lr function, so I know that it will work on subsets of images.

What I am looking to do is the following: From a source of ortho imagery, transfer any and all pixels that intersect with the tile grid, then move on to the next grid. There may be 10 source images (for example) that are large in size (geographic extent and disks space) that would be used to populate the individual grid tiles (ie: 1km X 1km).


1 Answer 1


I would build a GDAL virtual image using (something like):

gdalbuildvrt myimage.vrt images/*.tif

and then tile that using either gdal2tiles or gdal_retile:

gdal2tiles.py myimage.vrt outputDir


gdal_retile.py -tileIndex tileIndexName myimage.vrt 
  • I have had no luck with this. I have tried to use FWTools, MSYS Shell, and the .py in command prompt with no luck. When I run the gdal_retile.py in command prompt or FWTools, it gives a line error of the script. When I try to use MSYS Shell is says it can not find the file, even when I am dragging it in from explorer. Thoughts? Sep 5, 2013 at 23:07
  • I just tried it in OSGeo4W Administrator and it worked. I the command needed the output folder as a variable. Here is the command: gdal_retile -of GTiff -tileIndex <tile.shp> -r cubic -targetDir <tiled folder> merge.vrt Sep 5, 2013 at 23:13
  • When I review the tiling, it is not to the tile grid shape. The output tiles are squared, and not cut to the input tile boundaries. Sep 5, 2013 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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