[GRASSLIST:4201] Re: connect the dots

Gordon Keith gordon.keith at csiro.au
Tue Aug 17 19:57:56 EDT 2004


On Wed, 18 Aug 2004 07:36, SWlab wrote:

> I have a series of LL coordinates, in a given order, that I imported in
> GRASS57. I'd like to connect one site to another, for example in the
> category order. What should I do ?

What I did (there may be a better method):

Export the sites as an ascii file, 
reformat the file to the vector file format and 
import the vector file.

The following script should more or less do the job:

# export the sites as an ascii file
v.out.ascii sitesname > sites.txt

# reformat the file to the vector file format
GISDBASE=`g.gisenv get=GISDBASE`
LOCATION_NAME=`g.gisenv get=LOCATION_NAME`
MAPSET=`g.gisenv get=MAPSET`
VECTFILE=$GISDBASE/$LOCATION_NAME/$MAPSET/dig_ascii/vfile.txt

echo VERTI: > $VECTFILE
echo L   `cat sites.txt | wc -l  ` >> $VECTFILE

awk -F \| '{ print "  " $2 " " $1 }'  sites.txt >> $VECTFILE

# import the vector file
v.in.ascii in=vfile.txt out=vectorname

This connects all the sites as a single line in the order they appear in the 
sites file. 

If you want more than one line you need to add a line consisting of L and the 
number of points followed by the points to the end of the file. eg if 
sites2.txt contains the second line add:
echo L   `cat sites2.txt | wc -l  ` >> $VECTFILE
awk -F \| '{ print "  " $2 " " $1 }'  sites2.txt >> $VECTFILE

You can obviously create the vfile.txt by hand, just remember it has to be in 
the dig_ascii directory.

The man page for v.in.ascii should cover the details.

Hope this helps
Gordon
-- 

Gordon Keith
Programmer/Data Analyst
Marine Acoustics
CSIRO Marine Research
http://www.marine.csiro.au

The main thing is keep the main thing the main thing.




More information about the grass-user mailing list