[GRASSLIST:223] Re: Reading/writing maps

David Finlayson dfinlays at u.washington.edu
Tue May 27 12:54:21 EDT 2003


I suppose I should move to the developer list to keep from boring 
everyone not interested in Python, but, I never considered myself a 
developer...just a user trying to get things done.

The ESRI ASCII header defines a NODATA value, typically -99999.  My 
class stores this value (along with the rest of the header information) 
as an attribute of the class.  Otherwise, my Python class has no 
knowledge of Null values and will happily calculate these values just 
like real data.  Since I used arrays from the numeric package in python 
for efficiency it is a requirement that the whole raster by a single 
type (i.e., floating point, integer, etc.) so I can't simply substitute 
a Null value in for the -99999.

There would be a penalty for checking each read for null values before 
processing.  I ran into a similar problem when I wrote code to get 
values using either row and column notation or northing and easting.  I 
wanted to check that each entry was within the bounds of the grid before 
attempting the operation.  When I ran the code on a large dataset, I 
found that the code spent a huge amount of time in the bounds checking 
methods.  It was a performance killer.  But then again, when I code, I 
have a knack for finding the worst possible way of doing things.  (I am 
a geologist with 1 class in numerical methods.  Very dangerous!!)

Maybe later this summer I can take a stab at writing a real python 
interface and see if people like it enough to invest energy into this. 
I will need help with the C code however.

Cheers,

David

Russell Nelson wrote:
> Glynn Clements writes:
>  > One question: how do you handle nulls?
> 
> I don't know how David handles it, but Python has a native 'None' value.
> 
>  > For handling rasters, you wouldn't need to use all that many
>  > functions; e.g. r.mapcalc only uses 49 GRASS functions.
> 
> Still, you never know what people are going to want to do in Python.
> Better to just wrap everything, and let people at it.
> 

-- 
David Finlayson
School of Oceanography
Box 357940
University of Washington
Seattle, WA  98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays




More information about the grass-user mailing list