[GRASS-dev] [GRASS GIS] #3680: [PATCH] r.object.geometry: add output of mean coordinates of objects - difference to r.mapcalc/r.univar output
GRASS GIS
trac at osgeo.org
Wed Oct 10 08:56:38 PDT 2018
#3680: [PATCH] r.object.geometry: add output of mean coordinates of objects -
difference to r.mapcalc/r.univar output
------------------------------------------------+-------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Addons | Version: unspecified
Keywords: r.object.geometry cell coordinates | CPU: Unspecified
Platform: Unspecified |
------------------------------------------------+-------------------------
For some applications it can be useful to obtain the mean coordinates of
raster objects. I would like to add this functionality to
r.object.geometry. For this I use the attached patch.
However, when I use this to calculate mean coordinates of objects, I get
one unit of resolution difference between these results and the results of
the following r.mapcalc/r.univar call:
{{{
g.region rast=MyMap
r.mapcalc "x = x()"
r.univar -t x zones=MyMap
}}}
Here's some output for comparison:
{{{
r.mapcalc/r.univar r.object.geometry
zone|mean cat|mean_x
1|270347.103514056 1|270347.353514
2|270355.499712833 2|270355.749713
3|270243.128030303 3|270243.378030
4|270270.053380443 4|270270.303380
5|270280.90239726 5|270281.152397
6|270277.778301887 6|270278.028302
}}}
The result of r.object.geometry is always shifted one resolution (0.25) to
the East.
However, y values are not:
{{{
r.mapcalc/r.univar r.object.geometry
zone|mean cat|mean_x
1|154056.164959839 1|154056.164960
2|153996.903084224 2|153996.903084
3|154041.199242424 3|154041.199242
4|154016.742456073 4|154016.742456
5|154017.476598174 5|154017.476598
6|154017.057193396 6|154017.057193
}}}
Is the error in my patch, or maybe in the r.mapcalc x() function ?
Any objections to applying this patch ? It changes the output of the
module, but it add the additional values at the end, so unless some
scripts rely on fd being the last value, this should not cause too much
trouble.
Moritz
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3680>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list