[GRASS-dev] Rast_open_new_null()

Hi,

is there a small way to open a new file and set all values to NULL?

The function would be something like Rast_open_new_null(),

Yann

Yann,
You could just use r.reclass on an existing layer and set everything to NULL,
http://grass.osgeo.org/grass64/manuals/r.reclass.html

Doug

···

On Mon, May 27, 2013 at 11:38 PM, Yann Chemin <ychemin@gmail.com> wrote:

Hi,

is there a small way to open a new file and set all values to NULL?

The function would be something like Rast_open_new_null(),

Yann


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Doug Newcomb
USFWS
Raleigh, NC
919-856-4520 ext. 14 doug_newcomb@fws.gov

The opinions I express are my own and are not representative of the official policy of the U.S.Fish and Wildlife Service or Dept. of the Interior. Life is too short for undocumented, proprietary data formats.

On Tue, May 28, 2013 at 5:38 AM, Yann Chemin <ychemin@gmail.com> wrote:

Hi,

is there a small way to open a new file and set all values to NULL?
The function would be something like Rast_open_new_null(),

Using a module:
r.mapcalc "newmap = null()"

Using C code:

int row, nrows;
int data_type;
void *buf;

data_type = <one of CELL_TYPE, FCELL_TYPE, DCELL_TYPE>

/* open raster map ... */

buf = Rast_allocate_buf(data_type);

Rast_set_null_value(buf, Rast_window_cols(), data_type);

nrows = Rast_window_rows();

for (row = 0; row < nrows; row++) {
    Rast_put_row(buf, data_type);
}

/* close raster map ... */

Markus M