[GRASS-user] changing raster values in r.example
Markus Metz
markus.metz.giswork at gmail.com
Thu Jun 27 12:42:46 PDT 2013
On Thu, Jun 27, 2013 at 4:50 PM, Pedro Mendonça <pfmendonca at fc.ul.pt> wrote:
> 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:
>
> //********
this
> for (row = 100; row < 200; row++)
> {
must be
for (row = 0; row < nrows; row++) {
Otherwise the result will be an incomplete raster map. Did you get any
warnings or errors when executing your module?
Markus M
> 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
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
More information about the grass-user
mailing list