[Gdal-dev] Clip raster by percentage?

Frank Warmerdam warmerdam at pobox.com
Tue Mar 18 09:54:20 EDT 2008


Pål Kristensen wrote:
> Hi!
> 
> I it possible to clip a GeoTiff by a given percentage from each side (ie 5%
> from top, 2% from bottom, and so on) with GDAL, and if so, how is it done?

Pål,

This is not directly provided for - no.   You would basically need to figure
out what pixel-line window it amounts to and use that with gdal_translate and
the -srcwin switch.

For example for a 1000x1000 image you might use:

   gdal_translate -srcwin 50 50 930 930 in.tif out.tif

would be 5% off the top and left, and 2% off the right and bottom.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list