[GRASS-dev] Re: [GRASSLIST:962] Re: GRASS and vector lines: how can I change the direction of digitized lines?

Maciek Sieczka werchowyna at epf.pl
Mon May 15 13:37:45 EDT 2006


Hamish, All,

Improved (still to be improved further) v.flip 1.1 is attached. Please
take a look at my writing below.



On Mon, 15 May 2006 15:29:03 +1200
Hamish <hamish_nospam at yahoo.com> wrote:

>some hints follow,

<snip>

> Maciek wrote:

>> 2. I use "v.clean tool=snap thresh=0.01" to re-connect the flipped
>> and the remaining original lines. Is it 100% robust? No risk that
>> some won't be connected?

>If anything I would make thresh much smaller so that no new lines are
>snapped. The coordinates should not be changed unless you did printf %f
>from awk (shortens decimal precision, use %s to output full input
>string instead of proccessing as a number). So snapping should be
>exact.

I see. I don't do any maths on coordinates, I only use awk to select
particular lines from v.out.ascii output and pipe them into another
file, in a given order, so I should be on the safe side here.

Is it possible to estimate what treshold should be enough? 0.0001,
else???

>eval `g.findfile element=vector file="$INPUT"`
>    if [ ! "$file" ] ; then
>
>can be shortened, g.findfile returns 1 if the file wasn't found.
>see r.blend:
>http://freegis.org/cgi-bin/viewcvs.cgi/grass6/scripts/r.blend/r.blend?rev=HEAD
>
>just leave those tests out for input= and output=, g.parser checks
>that maps do/don't exist given the rules in "#% gisprompt :",
>--overwrite, etc.

These are cool, thanks. Done.

>Call temporary maps like tmp_vflip_$$_toflip:
>tmp_${PROG} makes it easy to spot orphans, $$ gives it a 1 in 32k
>chance of being unique.

I'm already using $$, I think (TMP="`g.tempfile pid=$$`"). Is this
what you mean? Added $PROG, thanks.

>It is easier to read, if instead of
>
>output=$OUTPUT"_toflip"
>  you do
>output=${OUTPUT}_toflip
>  or
>output="${OUTPUT}_toflip"

Is the 1st one error prone or only "not nice"?

Is any of the 2 you recommend better? I'll correct my script
accordingly.

>you probably want to use "sort -n" instead of "sort" so you don't get
>1
>13
>2
>20
>etc.

In my case it doesn't matter - I only need to put identical words one
after another to filter out only 1 instance of each of them with uniq.

>asis=`cat $TMP.cat_asis`
>asis=`echo $asis | sed 's/ /,/g'`
>probably hit the limitied size cap for a shell variable? (4096 chars?)
>Use a tmp file.

Hmm, $asis is an input in the line 129:

v.extract -t layer=$LAYER input=$INPUT list=$asis output=
$OUTPUT"_leaveasis"

list= has to be a single, long string of numbers separated with ",". So
even if I avoid hitting the 4096 chars limit of a bash variable by
doing all in a TMP file, I will finally have to pass it to "v.extract
list=" as a one string, which will make it fail if the string is
longer than 4096 (is my thinking correct?).

A possible workaround would be to to convert long, continous sets
like eg. 1,2,3,4,5,...,100 into 1-100 and so on to save space. Is there
an easy way of doing it?


>for a in $start_stop
>do
>..
>done
>
>make it easier to follow by indenting the inner part of the loop by a
>few spaces.
>
>see also v.out.ascii.db (wiki add-ons) and v.in.garmin (complex awk+tac
>vector ascii format flipping to count vertices) scripts.

Thank you very much for all the hints. I really appreciate your help.

All Best,
Maciek


--------------------
W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.panoramainternetu.pl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v.flip_11
Type: application/octet-stream
Size: 4975 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20060515/a009ac37/v.obj


More information about the grass-dev mailing list