[GRASS-dev] easy way to load x, y (of centroid) and top, bottom, left, right coordinates to attribute table?

Helmut Kudrnovsky hellik at web.de
Sat Jan 28 04:11:02 PST 2017


>I don't know which tool you used in QGIS, 

it's quite easy in QGIS, just open the attribute table for editing and type

x (centroid(  $geometry )) 
y (centroid(  $geometry ))

in the calculator for calculating the centroid coordinates.

>but GRASS' centroids are not
>guaranteed to be the geometrical centroid (aka "center of gravity" which
>could sometimes fall outside the polygon). 

ah yes, you're right.

>You might want to compare the
>results of QGIS with those of the addon v.centerpoint. 

v.centerpoint input=testcalculate output=testcalculate_center_of_gravity 

v.db.select map=testcalculate_center_of_gravity columns=x,y,x3,y3         
x|y|x3|y3
9.8489673562|47.0568937369|9.8489673562097|47.0568937369153
11.8802743895|46.9879350674|11.880274389498|46.9879350674375
9.7422504597|46.163754262|9.74225045972473|46.1637542620065

yes, GRASS' "center of gravity" (x3,y3) and QGIS centroids (x,y) are the
same. 

thanks




-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/easy-way-to-load-x-y-of-centroid-and-top-bottom-left-right-coordinates-to-attribute-table-tp5305135p5305180.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


More information about the grass-dev mailing list