0

This seems like a simple process but somehow I am not able to solve this. The situation is as follows: I have three separate lines which form visually 1 line. As I want to further process these lines they have to be "merged" into 1 line from a topology side of view.

The lines are build from a thinned raster. Nodes numbers are counted anew for each line.

The attribute table is as follows:

  • Layer 1
  • cat: 1-3
  • value: length

I have tried the following tools:

  • v.edit to try to merge
  • v.build.polylines
  • v.dissolve

I might have used to wrong parameters or did not select certain options in the right way. I tried to search for similar topics and tried several solutions but as of yet to no avail.

Line example showing the IDs and number of nodes denoted as n_x

  • 1
    THe correct module for this is v.build.polylines. The only requirement is that the start/end nodes of the separate lines must exactly intersect. So you might need to run v.edit ... tool=snap snap=node first, with a threshold slightly larger than the resolution of the original raster. – Micha Jun 9 at 12:39
  • Thank you for your reply. I have included a picture to my problem. Using the v.edit tool already seems to solve the problem indeed! – MarcM Jun 10 at 14:07
  • This seems to work if I run the tool in the console just fine, however if I want to run it in a python file I get the following error: GRASS_INFO_MESSAGE(14999,5): r.to.vect complete.GRASS_INFO_END(14999,5)ERROR: Unable to open file <result> If I specify both the map and input as follows: gscript.run_command('v.edit', map=line_single, tool='snap', ids=[1-50], snap='node', input= line_single, threshold=[-1,0.016,0], env=env) If I leave out the input statement the code does not give me an error but does not execute the edit I want to make. – MarcM Jun 10 at 14:35
  • 1
    I'm quite sure you do not want to use input=. That's only to specify an ASCII vector format file to add features to an existing GRASS vector. Can you post the exact python commands you are trying to run, and the outputs? – Micha Jun 11 at 18:23
  • Removing the input parameter indeed solved the problem! Thanks again! – MarcM Jun 12 at 13:49

Your Answer

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

Browse other questions tagged or ask your own question.