[GRASS-user] Getting raster cell coordinates

Allar Haav allar.haav at gmail.com
Thu May 2 04:40:14 PDT 2013


Hi,

What would be the most efficient way of getting the coordinates for each 
input raster cell? I'm using this in a Python script that creates a 
separate cost surface (using r.cost) for each cell (yes, that is 
computationally intensive thing indeed, but that's not a problem 
itself). I've been using a simple function I made that creates a list of 
coordinates via iteration starting from the region corner and using 
cellsize as a step. But this does not check for null-values in the 
raster (which I would like to exclude) and I'm also not very sure how it 
would play out with some coordinate systems. One way to solve the 
null-value issue would be to impose an r.what check, but this does not 
seem to be very elegant way to do it.
Any suggestions? I'm more or less comfortable with using ctypes, so that 
route would perhaps be the best in terms of performance.

Regards,
Allar


More information about the grass-user mailing list