[GRASS-user] Re: Extracting centroids as a raster (and are these centroids really at the center?)

Markus Neteler neteler at osgeo.org
Mon Jan 9 10:28:50 EST 2012


On Mon, Jan 9, 2012 at 3:49 PM, Marcello Gorini <gorini at gmail.com> wrote:
> Now the centroids are in the center :)
> You can see in the attached image the new ones in pink. Great!

Excellent.

> But I encountered a few problems to get there. I don't know if it is
> something with me or my system (6.4.0svn on old ubuntu 9.1), but the script
> wasn't looping correctly over the different areas.

Honestly, I tried only with a one area map and updated the script to the
posted stage after midnight :p

> It seemed that r.category was ignoring the mask created in the loop and that
> was causing trouble. So, instead of using r.mask, I actually created a
> temporary raster containing only the selected area in the loop. I also put
> the area calculation with r.stats inside the loop.

Yes, right.

> Also, as you instructed, I made the program output the centroid coordinates
> to a file and then use it as input to r.in.xyz to create the raster. It
> worked as a charm!
>
> Thanks again,
> Marcello.
>
> P.S.; I also attached the modified r.centroid.new if you would like to take
> a look. I hope I didn't deform your script too much :)
...
> http://osgeo-org.1803224.n2.nabble.com/file/n7168100/r.centroid.new

excellent!

Cheers
Markus


More information about the grass-user mailing list