[Gdal-dev] Clip raster by percentage?

Pål Kristensen pal.kristensen at statkart.no
Tue Mar 18 10:03:02 EDT 2008


Hi!

Thanks for helping! I will use the method you described them. Maybe I'll try
to  make a small python script that calculates the values for each raster
and runs the command in batch.

Regards,
Pål Kristensen


Frank Warmerdam-2 wrote:
> 
> 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
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/Clip-raster-by-percentage--tp16117341p16121911.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.



More information about the gdal-dev mailing list