[GRASS-user] changing raster values in r.example

Pedro Mendonça pfmendonca at fc.ul.pt
Thu Jun 27 07:50:15 PDT 2013


Hi.
 I'm starting to write a simple program based on r.example.
 For now the goal is to read a DEM file, change some values, and write out another DEM file with the changed values.

The r.example creates the second DEM file but with the default region (how can I change the region?) and does nothing to the values.
So, I tried this:

//********
for (row = 100; row < 200; row++)
	{
		if (G_get_raster_row(infd, inrast, row, data_type) < 0)
			G_fatal_error(_("Unable to read raster map <%s> row %d"), name, row);

		for (col = 240; col < 350; col++) {			
			((CELL *) outrast)[col] = 2000;
		}
	
		if( G_put_raster_row(outfd, outrast, data_type) < 0 ) {
			G_fatal_error(_("Failed writing raster map <%s>"), result);
		}
	}
//********

But it's not writing the changed values.
I even tried changing the r.example as little as possible just changing this function:

//********
CELL c_calc(CELL x)
{
    x = x + 2000;
    return x;
}
//********


But still didn't work. Any clues why it's not writing?
Thanks


More information about the grass-user mailing list