HOWTO get centroid coordinates
Jump to navigation Jump to search
Q: 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?
A: In Grass 6.4.x:
# 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
In Grass 7:
v.out.ascii in=poly type=centroid