[GRASS-user] Getting raster cell coordinates

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

Are you using pygrass?

On May 2, 2013 5:10 PM, “Allar Haav” <allar.haav@gmail.com> wrote:

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


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Allar wrote:

What would be the most efficient way of getting the
coordinates for each input raster cell?

...

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?

r.out.xyz does just that.

Hamish

Ah, this is indeed what I was looking for.
Thanks!

Allar
  

r.out.xyz does just that.

Hamish