[GRASS-user] v.overlay + script

Giovanni Pasini jynxtor at gmail.com
Thu Jul 23 11:31:49 EDT 2009

Hello everybody,
I have a question about v.overlay, (... sorry about my english)

Some vect:
from=railway (polygon)
to=streets (polygon)
sn=3 (snap thresold in meters)

with railway that run next to a street from streets layer whith some 
little overlaps and gaps

I have add railway some vertices (v.edit tool=vertexadd) -> ${from}_mod 
and then I make:

v.edit ${from}_s tool=create --o
v.out.ascii ${from}_mod format=standard | v.edit ${from}_s tool=add 
th=-1,$sn,0 bgmap=temp_${from}_${to} snap=vertex --verbose #where 
temp_${from}_${to} is a vector of points (see script at bottom of the 
message and http://www.petaimg.com/u318/606fig4.png).

Now I have ${from}_s only slighty different from $from, now it is more 
close to $to (see http://www.petaimg.com/u253/302fig7.png and 

I want overlay the two maps:
v.overlay ain=${from}_s bin=${to} out=${from}_s_${to} op=or -> give me 
Some boundary in the south are deleted?? why?

v.overlay ain=${from}_mod bin=${to} out=${from}_mod_${to} op=or -> give 
me http://www.petaimg.com/u12/386fig6.png
is OK!?

I look for some topology problem in ${from}_s but it appear ok! How can 
I solve this problem?
I can post the vector files (as ascii), I'm running GRASS 6.4.0RC4 on a 
debian testing box.

Can you give some suggestion about snap_01.sh script?

Thanks in advance for the help,


sn=$3 #snap thresold in meters

#1) $from's points near vertex/node to $to
echo "Extraction nodes and vertex from $from, patch and v.category >> 
v.to.points -n in=$from out=${from}_n
v.to.points -v in=$from out=${from}_v
v.patch in=${from}_n,${from}_v out=${from}_tos_1
v.category in=${from}_tos_1 out=${from}_tos_2 opt=add lay=3
g.remove vect=${from}_n,${from}_v,${from}_tos_1

echo "Points' list on $to >> temp_${from}_${to}.txt"
v.distance -p from=${from}_tos_2 from_type=point from_lay=3 to=$to 
to_type=boundary up=to_x,to_y col=x,y dmax=$sn --o --q | grep -v null > 
temp_${from}_${to}.txt #from_cat|x|y
g.remove vect=${from}_tos_2

#2) $to's boundary vertex/node
echo "Extraction nodes and vertex from $to, patch and v.category  >> 
v.to.points -n in=$to out=${to}_n
v.to.points -v in=$to out=${to}_v
v.patch in=${to}_n,${to}_v out=${to}_tos_1
v.category in=${to}_tos_1 out=${to}_tos_2 opt=add lay=3
echo "cat to temp_${from}_${to}.txt"
v.to.db map=${to}_tos_2 opt=coor -p lay=3 --q >> temp_${from}_${to}.txt
g.remove vect=${to}_n,${to}_v,${to}_tos_1

cut -d "|" -f2,3 temp_${from}_${to}.txt | v.in.ascii 
out=temp_${from}_${to} skip=1 cat=0

g.copy vect=$from,${from}_mod

echo "vertexadd to ${from}_mod, log_vertexadd_${from}_mod.txt"
echo "start log: -----------------------------------------" > 
for coord in `v.distance --q -p from=${to}_tos_2 from_type=point 
from_lay=3 to=${from}_mod to_type=boundary up=to_x,to_y col=x,y dmax=$sn 
| cut -d"|" -f2,3 | grep -v -e 'x' -e 'null' | tr "|" "," `; do v.edit 
map=${from}_mod tool=vertexadd th=0.01 coords=$coord >> 
log_vertexadd_${from}_mod.txt 2>&1; done

echo "Makig of ${from}_s and snap to temp_${from}_${to}"
v.edit ${from}_s tool=create --o
time v.out.ascii ${from}_mod format=standard | v.edit ${from}_s tool=add 
th=-1,$sn,0 bgmap=temp_${from}_${to} snap=vertex --verbose

g.remove vect=${to}_tos_2


More information about the grass-user mailing list