I'm using gdalwarp to clip a number of geotiffs (tiles of a larger map) to a polygon described by a shapefile (which is about the size of the overall map, i.e. much larger than individual tiles) using:

gdalwarp -of GTiff -cutline shape.shp -crop_to_cutline tile.tif cropped_tile.tif

(where tile.tif actually iterates through all the map tiles in the full code)

This works fine, however the resulting tiles (cropped_tile*.tif) now cover the same geographic area as the shapefile, and consequently have much larger file sizes (2.5M -> 64M). Is there any way to clip the areas of the tiles which lie outside the polygon in the shapefile without making each tile cover the same area as the shapefile itself?


If your geotiffs are increasing so much in size it almost certainly means that the originals are compressed. With your current command the cropped files are uncompressed.

You can check the compression method which is used in your original images with gdalinfo http://www.gdal.org/gdalinfo.html. Use the same or select your favourite compression from http://www.gdal.org/frmt_gtiff.html and add creation option -co compress= into your gdalwarp command. However, notice that some compression methods do not suit well for warping big images which are written incrementally into destination file. Especially with jpeg compression the compression rate will not be optimal that way and it is better to create first an uncompressed image with gdalwarp and compress it with gdal_translate later.

  • Thanks for the response - compression may well help reduce the tile size, but I think that my issue is actually due to the geographic extent of the clipped tiles being changed to that of the shapefile. I've resolved this in a hacky way by resetting the extent of each flipped tile to its original extent using: gdalwarp -te <orig_left> <orig_bottom> <orig_right> <orig_top> clipped_tile.tif rescaled_tile.tif. If there's a better way of doing this (i.e. all in one step?) then please let me know! Sep 16 '14 at 16:56
  • Consider to combine the originals into a virtual mosaic with gdalbuildvrt ann warp and clip that as one entity.
    – user30184
    Sep 16 '14 at 17:01
  • Thanks for the advice - this works really nicely! One issue: after gdalwarp on the .vrt mosaic, I can produce one large geotiff, but I would like to split it back into geotiff tiles of a similar size to the originals. Is there any way to re-split the .vrt into constituent tiles after processing? Thanks Sep 16 '14 at 18:16
  • I would calculate the extents of the output tiles beforehand and feed them into -te parameters for gdalwarp.
    – user30184
    Sep 16 '14 at 18:21
  • ok, will do; thanks for the advice and quick responses - much appreciated. Sep 16 '14 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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