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

Andrea Antonello andrea.antonello at gmail.com
Mon Oct 17 13:16:41 EDT 2005


Hi Maris,

> 1. How can I check is raster cell value null? foo[x][y]==NULL?
> 2. How can I save resulting raster map with null instead of "0"?
>
> Those Q's may sound lame, but, as I have only read "teach yourself C
> in 24 hours" style tutorial, I cannot understand GRASS null magic
> looking only on source.

I think the best thing would be to look into a simple module like for example 
r.sum and read the developers manual. It supplies all the functions you need.
For example some lines of r.sum

// for every row of the region defined in "w"
	for (row = 0; row < w.rows; row++) {

// this reads the row number "row" from the cellfile into the buffer tf
	    G_get_f_raster_row(cellfile, tf, row);

// for every column of the region defined in "w"
	    for(col=0; col < w.cols; col++){

// if the value in tf is null
		if (G_is_f_null_value (tf)) *tf = 0.0;

// move pointer one position
		tf++;
// and so on...

Functions like G_is_f_null_value, G_get_f_raster_row are all well described in 
the developer's manual, which is a bible if you want to write a module.

Cheers,
Andrea


>
>
> tnx for reading,
> Maris Nartiss.
>
> _______________________________________________
> grass5 mailing list
> grass5 at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass5

-- 
____________________________________________________________________________
HydroloGIS - Environmental Open Source Solutions
www.hydrologis.com

Andrea Antonello
Environmental Engineer
mobile:  +393288497722

"Let it be as much a great honour to take as to give learning,
if you want to be called wise."
Skuggsja' - The King's mirror - 1240 Reykjavik
____________________________________________________________________________





More information about the grass-dev mailing list