[GRASS-dev] How to: if undefined, set to NULL?

Nikos Alexandris nik at nikosalexandris.net
Sun Sep 4 06:45:50 PDT 2016


Nikos Alexandris:

>>>    if (chroma == 0.0) {
>>>
>>>        saturation = 0.0;
>>>
>>>        /* undefined -- (how to) set to NULL? */
>>>        hue = 0.0;

>>> I'd like to set hue to NULL, whenever the condition is met. How do I do
>>> that?

Markus Neteler:

>>Something like:
>>
>>    for (row = 0; row < nrows; row++) {
>>        G_percent(row, nrows, 5);
>>        for (col = 0; col < ncols; col++) {
>>            cell_buf[col] = bas[SEG_INDEX(ba_seg, row, col)];
>>            if (cell_buf[col] == 0)
>
>>                Rast_set_null_value(&cell_buf[col], 1, CELL_TYPE);
>
>Alright, that is:  anything that `&cell_buf[col]` points to, set the
>number of values `1` to NULL.

Updated in sandbox, see: https://trac.osgeo.org/grass/changeset/69365

Is it though correct?

Nikos


More information about the grass-dev mailing list