[Qgis-developer] Raster resampling

Marco Hugentobler marco.hugentobler at sourcepole.ch
Tue Jan 17 07:32:31 EST 2012


Hi Radim

 >Have you considered a possibility to pass resampling to a driver in
 >case it supports resampling? At least GDAL supports resampling,
 >currently used GDALRasterIO does not, GDALWarp does. GDALWarp was
 >slow with reprojection, I don't know if resampling is better.

The problem here is that resampling sometimes can only be done once you 
know the pixel color. E.g. in case of paletted raster, two adjacent 
pixel values can have totally different color (therefore resampling 
needs to be done on color components, not on raster value). I guess that 
this is the reason why GDALRasterIO does not support resampling (and is 
implemented in GDALWarp and UMN mapserver on a higher level, comparable 
to QgsRasterLayer).
How is it with GRASS? it probably has the resampling on a lower level?

>I am especially concerned about reprojection, because reprojection of
>images oversampling^2 times bigger may be significantly slower.

  True, I need to do some more tests here. At the moment, the 
oversampling rate is kept at a maximum of 4 (that should probably be a 
user option later). Ok, maximum 16 times more data to reproject 
(hopefully no problem with your approximative reprojection :-) ).

Relatively soon, I'd like to implement the option to select different 
resampling types for zoomed-in and zoomed-out situations. Often, people 
like to have e.g. bilinear for zoomed-in and average for zoomed out.


Regards,
Marco

On 16.01.2012 22:23, Radim Blazek wrote:
> Very good,
> I appreciate also the side effects like moving rendering methods to
> QgsRasterRenderer.
>
> Have you considered a possibility to pass resampling to a driver in
> case it supports resampling? At least GDAL supports resampling,
> currently used GDALRasterIO does not,  GDALWarp does. GDALWarp was
> slow with reprojection, I don't know if resampling is better.
>
> I am especially concerned about reprojection, because reprojection of
> images oversampling^2 times bigger may be significantly slower.
>
> Maybe just resampling before reprojection could be considered.
>
> Question for all: is it better to resample images before or after
> reprojection? I am thinking especially about dissimilar projections
> where resolution ratio between source and destination is not constant
> over the extent.
>
> Radim
>
> On Fri, Dec 30, 2011 at 2:58 PM, Marco Hugentobler
> <marco.hugentobler at sourcepole.ch>  wrote:
>> Hi devs,
>>
>> Recently, I've been working on adding raster resampling to QGIS raster
>> (http://www.sourcepole.com/raster-resampling-in-qgis). The changes are in
>> the branch 'raster_resampler' of my github clone
>> (git://github.com/mhugent/Quantum-GIS.git).
>>
>> To add resampling in a clean way, I started a bit of refactoring within
>> QgsRasterLayer:
>>
>> - The new abstract class QgsRasterRenderer is added to replace the
>> drawingType switch. The method QgsRasterRenderer::draw() is a replacement
>> for the methods drawMultiBandColor(), drawMultiBandSingleBandGray(),
>> drawPalettedSingleBandColor(). This should move a lot of code out of
>> QgsRasterLayer and reduce code complexity. Currently implemented are
>> QgsPallettedRasterRenderer, QgsMultibandColorRenderer,
>> QgsSingleBandGrayRenderer
>> - The functionality of QgsRasterBuffer to draw the raster layer in several
>> parts is moved to QgsRasterRenderer base class (same idea of reducing
>> complexity in QgsRasterLayer).
>> - QgsRasterResampler has two subclasses for now, QgsBilinearRasterResampler
>> and QgsCubicRasterResampler (maybe average would be useful as well?)
>>
>> Any objections or suggestions about this? The code in the branch is mostly
>> working, but far from being complete.
>> I'm going to be without internet connection the next few days, but hope to
>> get the code to a testable state soon.
>>
>> Regards,
>> Marco
>>
>>
>> --
>> Dr. Marco Hugentobler
>> Sourcepole -  Linux&    Open Source Solutions
>> Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
>> marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
>> Technical Advisor QGIS Project Steering Committee
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer


-- 
Dr. Marco Hugentobler
Sourcepole -  Linux&  Open Source Solutions
Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee



More information about the Qgis-developer mailing list