[GRASS-dev] r.resamp.stats method=sum artifacts

Glynn Clements glynn at gclements.plus.com
Fri Nov 3 17:51:15 EST 2006


Dylan Beaudette wrote:

> I have been noticing some odd edge effects when using r.resamp.stats 
> method=mode .... i.e. i am getting a "ring" of cells with 0-value around the 
> actual data. Within the "ring" the results appear to match those obtained 
> with an alternate raster-vector-starspan-raster approach to doing the same 
> operation.
> 
> a graphical summary can be found here:
> http://169.237.35.250/~dylan/temp/method_mode-test.png

I wasn't making the source window large enough, with the result that
edge cells were using garbage values from outside of the source
buffer.

[r.resamp.stats was derived from r.resamp.interp. The window-setting
code was left untouched, but r.resamp.interp only needs source values
corresponding to the destination cell's centre +/- 2 source cells,
while r.resamp.stats needs source values for the whole of the
destination cell's area.]

I've committed the attached patch to CVS. Let me know if you still
encounter problems.

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

-------------- next part --------------
Index: main.c
===================================================================
RCS file: /grassrepository/grass6/raster/r.resamp.stats/main.c,v
retrieving revision 1.6
diff -u -r1.6 main.c
--- main.c	31 Oct 2006 22:34:41 -0000	1.6
+++ main.c	3 Nov 2006 22:40:00 -0000
@@ -290,14 +290,10 @@
 
 	/* enlarge source window */
 	{
-		double north = G_row_to_northing(0.5, &dst_w);
-		double south = G_row_to_northing(dst_w.rows - 0.5, &dst_w);
-		int r0 = (int) floor(G_northing_to_row(north, &src_w) - 0.5) - 1;
-		int r1 = (int) floor(G_northing_to_row(south, &src_w) - 0.5) + 3;
-		double west = G_col_to_easting(0.5, &dst_w);
-		double east = G_col_to_easting(dst_w.cols - 0.5, &dst_w);
-		int c0 = (int) floor(G_easting_to_col(west, &src_w) - 0.5) - 1;
-		int c1 = (int) floor(G_easting_to_col(east, &src_w) - 0.5) + 3;
+		int r0 = (int) floor(G_northing_to_row(dst_w.north, &src_w));
+		int r1 = (int) ceil (G_northing_to_row(dst_w.south, &src_w));
+		int c0 = (int) floor(G_easting_to_col(dst_w.west, &src_w));
+		int c1 = (int) ceil (G_easting_to_col(dst_w.east, &src_w));
 
 		src_w.south -= src_w.ns_res * (r1 - src_w.rows);
 		src_w.north += src_w.ns_res * (-r0);


More information about the grass-dev mailing list