In my previous post I explained how to add geometry values to the attribute table of a vector map in QGIS. You can do the same in GRASS GIS. It is slightly more complicated (don’t worry, it is still easy enough), but also more powerful. Below I will briefly explain how to use this tool using the GUI or command line. You’ll need the v.to.db function. You can type this in the console or through the menu (menu | vector | update attribute), which both will give you the following screen: As you can see, you are presented with quite a few option. But before we go into these options, it is important to realize that v.to.db can write values to existing columns only. It means you first need to create a column in the attribute table which will hold your geometry value. Type v.db.addcolumn on the command line or use the menu Database | vector database connection | add column. Give the name of the vector layer and the name of the new column and data type. For example, create a column ‘Area’ to hold the surface area of the polygons. The data type should be double precision. Or, type on the command line Having done that we can go back to v.to.db. In the first tab on the screen (Figure 1), fill in the vector layer and the value to be uploaded. There are various values that can be uploaded. Check the manual to see what these different values are. You normally should not be concerned with the ‘Layer numbers’ and ‘Query layer number’ options, but check the manual if you want to know more about these option. You can skip the ‘Query’ tab, that is if you want to update the values of a column based on other columns in the attribute table. The ‘Print’ tab is there is you want to print the results to the console instead of uploading the values to the attribute table. In the ‘Optional’ tab (Figure 3), you can mark for which feature types you want to calculate the values. Furthermore you can indicate in which units you want these values (e.g., surface areas can be in acres, hectares or square meters, kilometers, feet, or miles). The last thing to fill in is the name of the attribute column(s). Of course, you can use the command line, which is only two lines if you include the command to create the column: That’s all, and remember, the GRASS manual pages are generally pretty clear and often give some good examples. Source.