[gdal-dev] trying to change regionator image resampling to nearest-neighbor

Frank Warmerdam warmerdam at pobox.com
Thu Nov 12 15:17:19 EST 2009


Mary Jo Brodzik wrote:
> 
> Dear gdal-dev list members,
> 
> I'm using a python tool called the regionator 
> (http://code.google.com/p/regionator/wiki/ Welcome) on a large 
> (14352x7440) png image.  The regionator uses the GDAL library to 
> resample subsets of the original image into much smaller chunk images.  
> These images are set up at increasing levels of detail in a kml file 
> that make the download of this information into a googleEarth client 
> much more efficient.
> 
> The png is color and includes transparency; its approximate resolution 
> is 500 meters. I basically have 4 colors in the original image, black, 
> white, blue and yellow. The output images that regionator is producing 
> are great, but when I zoom in to distances where the original pixel 
> sizes are visible, it looks like the resampling did some averaging 
> across the 4 colors, so I'm getting blue sections surrounded by a blue 
> halo that bleeds into white, and yellow and blue values bleeding into 
> each other, etc.
> 
> I'd like to control the resampling, and force it to do nearest-neighbor 
> rather than averaging to eliminate the halos.  It looks to me like the 
> regionator is doing the resampling with calls to ReadRaster and 
> WriteRaster in in a class called extractor.py, but I don't know enough 
> about the GDAL libraries to know how to change them. Is it possible to 
> force the resampling to be nearest neighbor?  extractor.py isn't 
> terribly large or complicated, so I'm including it here (below).

Mary Jo,

ReadRaster() cannot itself be modified to do bilinear resampling.

I would suggest you try out gdal2tiles.py which does something similar
to regionator but with many more options.

   http://www.gdal.org/gdal2tiles.html

You might also find MapTiler of interest:

   http://www.maptiler.org/

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    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list