Vincent, I have tried your workaround, and it works with gdal_translate, with 
the following restriction:

1) 
with gdal_translate -outsize option, the dimensions of the input raster MUST be 
a multiple of the desired resolution (or modified with srcwin),  or else the 
output resolution will be  modified

for example:
input clip2.tif :Size is 125, 144, Pixel Size = 
(30.000000000000000,-30.000000000000000)

> gdal_translate -outsize 50% 50% clip2.tif clip2-tr-50-mode.tif

output  clip2-tr-50-mode.tif :  Size is 62, 72, Pixel Size = 
(60.483870967741936,-60.000000000000000)

Could I use gdal_translate without having to calculate dimensions which are a 
multiple of desired resolution?

2)
one could use gdalwarp -tr 60 60 (as per your suggestion), except that it 
doesn't use the overlays, as per bug 2076:
 http://trac.osgeo.org/gdal/ticket/2076


many thanks,
Etienne

----- Original Message -----
From: Vincent Schut <[email protected]>
To: [email protected]
Cc: 
Sent: Friday, August 5, 2011 4:37:42 AM
Subject: Re: [gdal-dev] help resampling raster to coarser scale

On 08/05/2011 03:57 AM, Etienne wrote:
> Hi all,
> 
> 
> I am trying to resample a raster with categorical data (land surface 
> vegetation/cover) from a high resolution (500m) to a coarser resolution.  
> I would like to do something similar to what the GRASS operator 
> r.resamp.stats does, using the modal category present in the higher 
> resolution dataset to pick the value in the lower-resolution map.  It seems 
> that my only option using gdal_warp is nearest neighbor, which will pick the 
> value nearest to the coarser pixel center (regardless of the most present 
> category within the region).
> 
> I would also like have a low-resolution map with the proportions of all land 
> types (from the high resolution map).
> 
> Any idea on how to accomplish what I want using gdal?  I am not familiar with 
> GRASS, and would prefer to stick with GDAL if I can.  However, I am open to 
> any suggestions.

Etienne,

there is a workaround for this: gdaladdo, the tool to add overviews 
('pyramids') to a file, does support the mode operator. So what you could do is 
add overviews to your file such that the overviews cover the output resolution 
you want, and then you can resample with gdal_translate (when no projection 
change is necessary, just give it your desired output resolution, see the 
gdal_translate docs), or with gdalwarp (and use nearest). They should use the 
overview level that is closest to your output resolution for resampling.

Best,
Vincent.
> 
> Many Thanks
> Etienne
> _______________________________________________
> gdal-dev mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to