[GRASS-dev] Difficulties on accessing a CELL type raster- C rotine

Greetings

I’m doing a GRASS Module (in C) that uses a training area (raster) and bands from a group and it do some pixel checking for the training_area and sees if the value shopuld be in that training area (some statistical analysis quite easy to implement). But I’m having a lot of difficulties in “accessing” to data in training_area raster. I have used i.maxlik to access to data in group and in signature file (that I need) and r.example to access to training map but I’m not getting it.

For pixels where my training_map is null(), according to map display pixel query, if I print that value using: c = ((CELL *) inrast)[col]; I get
-2147483648 instead of null() or something.
Is this expected?

Thanks

Best regards
Pedro

Pedro Roma wrote:

For pixels where my training_map is null(), according to map display pixel
query, if I print that value using: c = ((CELL *) inrast)[col]; I get
-2147483648 instead of null() or something.
Is this expected?

Yes; that is the value used to represent integer nulls.

To test whether a value is null, use one of:

  int G_is_null_value(const void *, RASTER_MAP_TYPE);
  int G_is_c_null_value(const CELL *);
  int G_is_f_null_value(const FCELL *);
  int G_is_d_null_value(const DCELL *);

[In 7.0, these functions have been moved to the raster library, and
have "Rast_" as the prefix rather than "G_".]

In general, you can't test for nulls using "==" as the value used for
floating-point nulls is NaN, which isn't equal to itself.

--
Glynn Clements <glynn@gclements.plus.com>