[GRASS-user] integration of sample.c algorithms into r.resample

Dylan Beaudette dylan.beaudette at gmail.com
Wed Aug 9 16:12:49 EDT 2006


On Wednesday 09 August 2006 12:42, Glynn Clements wrote:
> Dylan Beaudette wrote:
> > A quick follow-up:
> >
> > in the source for r.resample, it looks like the resampling is done in
> > this loop:
> >
> > for (row = 0; row < nrows; row++)
> > 	{
> > 		if (verbose)
> > 			G_percent (row, nrows, 2);
> > 		if (G_get_raster_row (infd, rast, row, data_type) < 0)
> > 			exit(1);
> > 		if (G_put_raster_row (outfd, rast, out_type) < 0)
> > 			exit(1);
> > 		G_mark_raster_cats (rast, ncols, &cats, data_type);
> > 	}
> >
> >
> > ...via the NN style resampling associated with converting between regions
> > of differing resolution.. (?)
> >
> > Is this a correct interpretation?
>
> Yes. G_get_raster_row() etc automatically resample the raster data
> (using nearest-neighbour) to match the current region resolution,
> while G_put_raster_row() creates a map which matches the current
> region.

Thanks for the quick reply Glynn.

> If you want any other conversion, you have to keep switching regions,
> so that input maps are read at their native resolution, while output
> maps are written at the desired resolution.

Yikes. That does complicate things quite a bit. I wonder if G_get_raster_row() 
could be modified such that it can perform these three resampling strategies 
as well. i.e. such that if one wanted a different resampling approach in any 
function that uses G_get_raster_row(), it would be possible to specify 
bilinear or cubic convolution... Although this might be a monumental task.

> For this reason, you may want to keep your new resampling program
> separate from r.resample, as it will require a fundamentally different
> structure.

Sure. Perhaps a look at r.bilinear would be helpful. What I am envisioning is 
something like r.resample / r.bilinear that would integrate the three 
methods- as there doesn't appear to be an r.resamp.cubic solution.

Cheers,

-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341




More information about the grass-user mailing list