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

Glynn Clements glynn at gclements.plus.com
Wed Aug 9 15:42:18 EDT 2006


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.

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.

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

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list