[GRASS-dev] How to: if undefined, set to NULL?
Nikos Alexandris
nik at nikosalexandris.net
Sun Sep 4 06:21:55 PDT 2016
* Markus Neteler <neteler at osgeo.org> [2016-08-27 15:37:35 +0200]:
>On Sat, Aug 27, 2016 at 3:26 PM, Nikos Alexandris
><nik at nikosalexandris.net> wrote:
>> While modifying i.rgb.his,
>>
>> if (chroma == 0.0) {
>>
>> saturation = 0.0;
>>
>> /* undefined -- (how to) set to NULL? */
>> hue = 0.0;
>>
>> rowbuffer[0][sample] = (FCELL)hue;
>> rowbuffer[1][sample] = (FCELL)intensity;
>> rowbuffer[2][sample] = (FCELL)saturation;
>> }
>>
>>
>> I'd like to set hue to NULL, whenever the condition is met. How do I do
>> that?
>>
>> hue = NULL;
>>
>> does not work.
>
>No, it is done withRast_set_null_value()
>
>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.
I need a few more examples to understand. What is the "number of values"?
Could it be a series of multiple values?
Nikos
> }
> Rast_put_row(basin_fd, cell_buf, CELL_TYPE);
> }
>
>(random example, taken from r.water.outlet/main.c)
>
>HTH,
>Markus
--
Nikos Alexandris | Remote Sensing & Geomatics
GPG Key Fingerprint 6F9D4506F3CA28380974D31A9053534B693C4FB3
More information about the grass-dev
mailing list