[GRASS-user] How to get centroid coordinates

Margherita Di Leo diregola at gmail.com
Fri Aug 24 05:25:32 PDT 2012


Hi Alexander,

On Fri, Aug 24, 2012 at 11:42 AM, Alexander Muriy <amuriy at gmail.com> wrote:

> Hi Margherita.
>
> I have a vector of polygons and i want to create a vector of points with
>> the centroids of the polygons, with a connected table showing their
>> coordinates. Which is the simplest way to do that on G7?
>>
>>
> In GRASS 6.4.*:
> -- extract centroids from polygon map
> v.extract in=poly out=centr type=centroid
> -- if needed convert centroids to points
> v.type in=centr out=centr_pts type=centroid,point
> -- add attribute table to points
> v.db.addtable centr_pts col="x double,y double,z double"
> -- insert coords in table
> v.to.db TMP_centr_pts option=coor col=x,y,z
>
> I think in GRASS 7.0 it will be similar.
>

Yes, indeed.  I used:

v.extract in=poly out=centr type=centroid
v.type in=centr out=centr_pts from_type=centroid to_type=point
v.db.addcolumn map=centr_pts col="x double precision,y double precision"
v.to.db map=centr_pts option=coor col=x,y

Thanks!




-- 
Dr. Margherita Di Leo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20120824/05fc4e30/attachment.html>


More information about the grass-user mailing list