[GRASS-user] Command of the day: merge vector lines in a map

Wolf Bergenheim wolf+grass at bergenheim.net
Sun Oct 19 13:12:03 EDT 2008


Hello list,

I had a map of a city whose streets were split at each intersection.
This time I needed to make it so that each street be one line.

Not knowing a direct tool to do the job, I came up with the following
command I wanted to share with you.The command creates a script that
calls v.edit to merge the lines based on the street name.

Without further ado, here is the beast:

echo '#\!/bin/bash' > tmp.sh && v.db.select -c map=str columns=a_STNAME
| sort | uniq | sed s,'\(.*\)','v.edit map=str tool=merge
"'where=a_STNAME="'\1'"'"', >> tmp.sh

This generates tmp.sh, which does the job. There probably is a better
way to do it, but this is what did the job for me.

I use tcsh so it might not work with bash.

Happy GRASSing,
--Wolf

-- 

<:3 )---- Wolf Bergenheim ----( 8:>



More information about the grass-user mailing list