1

I have spatially superimposed points in two layers from which I want to copy one column of attributes to the other layer. In QGIS you can do this with 'Join attributes by location' which worked great.

Now I want to write these steps in an R script using the R package rgrass7, which allows me to include GRASS GIS in R. Unfortunately I can't find a suitable equivalent to 'Join attributes by location' in GRASS GIS.

To give more background information: I want to calculate the distance (as the crow flies) between locations and a river system. Therefore I calculated a network with v.net.connect and extracted the sections between the locations and the river with v.select.intersect. From this I got lines (of the sections), from which I could calculate the length with v.to.db, which I then saved in a column in the sections. Then I used v.to.points to create end nodes which got the length information. And now I want to copy exactly this length information into the attribute table of the locations. The places contain important information like a column with numbers which I need for further calculations and without I can't assign these points to other data later.

This may be a lot more complicated than it has to be, or 'thought around the corner', but in QGIS this method has worked.

A selected section between the location and the river with the length in the attribute table I want to transfer to sites:

A selected section between the location and the river with the length in the attribute table I want to transfer to sites.

3
  • Would v.what.vect help? It uploads vector values at positions of vector points to the table, grass.osgeo.org/grass78/manuals/v.what.vect.html
    – markusN
    May 19 '20 at 14:31
  • Thanks a lot! As far as I can see, only attributes from a table of a polygon map can be transferred to an attribute table of point vector maps, or vice versa. But I will try to generate polygons instead of points. In my example I get the error message: ERROR: Incompatible column types
    – mfindeisen
    May 19 '20 at 20:29
  • 1
    @markusN Thanks a million, it worked! I just forgot to add int to v.db.addcolumn. It also works with the lines generated with v.net.connect so I don't need to create the nodes anymore.
    – mfindeisen
    May 19 '20 at 22:04
2

(written upon the discussion above)

You may want to use v.what.vect which uploads vector values at positions of vector points to the table. Importantly, run v.db.addcolumn beforehand to have a column in the attribute table which can be populated with the results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.