[GRASS5] Newbies Q: dealing with nulls in raster maps

Glynn Clements glynn at gclements.plus.com
Tue Oct 18 11:38:53 EDT 2005


Mris Nartis wrote:

> I'm writing my first C app (after hello world ;) - a GRASS module.
> I managed to load raster into 2d array and do all stuff what I need,
> except when dealing with null values.
> 
> Q's:
> 1. How can I check is raster cell value null? foo[x][y]==NULL?

	int G_is_c_null_value(const CELL *cellVal);
	int G_is_f_null_value(const FCELL *fcellVal);
	int G_is_d_null_value(const DCELL *dcellVal);
	int G_is_null_value(const void *rast, RASTER_MAP_TYPE data_type);

> 2. How can I save resulting raster map with null instead of "0"?

	void G_set_c_null_value(CELL *cellVals, int numVals);
	void G_set_f_null_value(FCELL *fcellVals, int numVals);
	void G_set_d_null_value(DCELL *dcellVals, int numVals);
	void G_set_null_value(void *buf, int numVals, RASTER_MAP_TYPE data_type);

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




More information about the grass-dev mailing list