Extracting coordinates of points and writing them to the attribute table

From GRASS-Wiki
Revision as of 07:20, 27 March 2011 by ⚠️Landa (talk | contribs)
Jump to navigation Jump to search

The workflow below describes how coordinates can be extracted from points and how they can be written into the attribute table.

The example is based on a CSV-File:

674065.18600,3367985.59300,25.83
674066.43200,3367982.46800,25.96
674065.99100,3367983.83600,40.24
674065.92600,3367985.70100,26.00

Importing points

For the import of the CSV-File use v.in.ascii.

v.in.ascii -z input=/path/to/points.csv output=points format=point skip=0 x=1 y=2 z=3 cat=0

Add attribute table for vector

Through v.db.addtable an attribute table for the points is created.

v.db.addtable map=points layer=1 table=points columns="cat integer"

Connect the vector to the attribute table

Use v.db.connect to connect the vector with its corresponding table.

v.db.connect -o map=points table=points

Add columns

Use v.db.addcol to add the columns to the attribute table.

v.db.addcol map=points columns="x double precision, y double precision, z double precision"

Add coordinates

Use v.to.db to write the coordinates of the points into the attribute table.

v.to.db map=points opt=coor columns="x,y,z"

--TimNorwey 14:01, 26 March 2011 (PDT)