Centroid coordinates to database

2 messages Options
Embed this post
Permalink
Szabó Balázs

Centroid coordinates to database

Reply Threaded More More options
Print post
Permalink
Hi!

It is possible to extract the centroid coordinates into the database?
 
(Sorry about my english, I try to explain my probleme). I have a vector
grass polygon data with mysql database connection. But I want use just
the mysql database with the polygons centroid. So that's why I need
upload to the mysql database (like a column) their centroids
coordinates. So it is possible to get this coordinates in Grass??

many thanks: Balazs  

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Markus Neteler

Re: Centroid coordinates to database

Reply Threaded More More options
Print post
Permalink
2009/9/27 Szabó Balázs <[hidden email]>:
> Hi!
>
> It is possible to extract the centroid coordinates into the database?

Yes.

> (Sorry about my english, I try to explain my probleme). I have a vector
> grass polygon data with mysql database connection. But I want use just
> the mysql database with the polygons centroid. So that's why I need
> upload to the mysql database (like a column) their centroids
> coordinates. So it is possible to get this coordinates in Grass??

I would do (untested):

# add new columns
v.db.addcol mymap col="centr_x double precision, centr_y  double precision"
# transform coordinates to attributes:
v.to.db mymap type=centroid option=coor col=centr_x,centr_y
# check
v.db.select mymap

This will fail if a category (i.e. attribute row in the table) points to
more than one polygon. In that case, you could add a new table
as layer=2 and populate it with unique values for each polygon
first. Then do above on layer=2 to upload the centroid coodinates
there.

See:
http://grass.osgeo.org/grass64/manuals/html64_user/v.to.db.html

Hope this helps,
Markus
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user