[GRASS-dev] r.relief

Markus Neteler neteler at osgeo.org
Thu Apr 30 06:53:31 PDT 2015


On Thu, Apr 30, 2015 at 2:25 PM, Paulo van Breugel
<p.vanbreugel at gmail.com> wrote:
> Hi,
>
> When running r.relief (in GRASS7.1) on a integer DEM raster, the output is
> an integer map. Is this intended behavior?

It appears to be hardcoded:

raster/r.relief/main.c
    int out_type = CELL_TYPE;
...

but then it casts the input to DCELL for the calculation:

...
    /* open the elevation file for reading */
    in_fd = Rast_open_old(elev_name, "");
    elev_cell[0] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
    Rast_set_d_null_value(elev_cell[0], ncols);
    elev_cell[1] = (DCELL *) G_calloc(ncols, sizeof(DCELL));
    Rast_set_d_null_value(elev_cell[1], ncols);
    elev_cell[2] = (DCELL *) G_calloc(ncols, sizeof(DCELL));
    Rast_set_d_null_value(elev_cell[2], ncols);

    out_fd = Rast_open_new(sr_name, out_type);
    out_rast = Rast_allocate_buf(out_type);
    Rast_set_null_value(out_rast, Rast_window_cols(), out_type);
    Rast_put_row(out_fd, out_rast, out_type);
    out_size = Rast_cell_size(out_type);
...

> Would it be possible to have
> r.relief convert the layer to double precision / float automatically if the
> DEM is of CELL type?

Technically yes using Rast_get_map_type()
http://grass.osgeo.org/programming7/raster_2open_8c.html#a535b2939a9d3869ce09e7fc45c649929

but I wonder what the rationale was to define CELL_TYPE? Maybe Markus M knows.

markusN


More information about the grass-dev mailing list