[GRASS-dev] GRASS-Ctypes: Unable to trap null values in Raster

Sudipta Sarkar sdptsarkar2 at gmail.com
Wed Apr 13 16:46:24 EDT 2011


Hi Folks
I am trying to check for null values in input raster files using Python Ctypes interfaces.
First of all I am not sure how you do this using Ctypes. Heres what I am doing:
...............
for row_n in range(rows):
	# read a row of raster data into memory, then print it
	Rast_get_row(in_fd, in_rast, row_n, data_type)
	# Check for null value
	for col_n in range(cols):
		if(Rast_is_d_null_value(pointer(c_double(in_rast[col_n])))):
			in_rast[col_n] = 0.0

But this does not work as for all null values in the input raster map I am getting some value of "-2147483648" in my input buffer so the above check is failing. What am i doing wrong here and whats the best way to trap null values in input raster using Ctypes libraries? I suspect that value of "-2147483648" is probably some sort of string/ascii representation of "Null" but am not sure whats causing this conversion and how to avoid that and just trap null values plain and simple. 

Any suggestions from all of you will be most welcome!!

BTW I have done this effectively in C and also in Ctyoes while writing out grass raster but still clueless about the input part.


	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20110413/4c871c27/attachment.html


More information about the grass-dev mailing list