[GRASS-user] v.coordinate.sh - improve this script?

Hamish hamish_b at yahoo.com
Thu Jan 24 19:46:19 EST 2008


Gabriele N. wrote:
> http://www.nabble.com/file/p15063748/v.coordinate.sh v.coordinate.sh 
...
> I made a script (attached) for the definition of interactive text
> file (containing the coordinates input and output) to be loaded
> later in v.transform.
> 
> It is useful to write automatically coordinates in the text file.
...
> http://www.nabble.com/file/p15063748/v.coordinate.sh v.coordinate.sh 

error on line 92:
if [$vettoriale2 == '']; then

you must have spaces next to [] and should quote variables. better:
(-z means zero length string, -n means non-zero length string)

if [ -z "$vettoriale2" ] ; then


> The script is certainly improved. For example viewing points included
> (as eg in i.points on in d.path) or shifting automatically monitors
> or using snap for the insertion points etc. ...

if you use d.where with the middle mouse button you can connect points
with a line. Or your script can draw them using "d.graph -m". see
d.mark from the wiki addons page.

You can do some shell math to convert the coordinates to a snapped
version. (e.g. 1234567.89 -> 1234000.00 with some awk '%' modulus or
log transform + round + back transform magic)

you might like "d.zoom -f" to get panning options, etc.

Use "d.where -1" for single point.

> coord_1a=`cat coord_1 |head -n 1 | awk -F " " '{ print $1 " " $2 }'`

You don't really need `head` there, only data is sent to stdout.
but it doesn't hurt anything.

You might use g.tempfile for the temporary files so the script will
work from any directoy. (e.g. running script while not in home dir)


> I have no programming experience, and I hope that someone can help me
> improve.

that's what we're here for, to train others to become grass devels so
that they can help others....

> Necessary installing xdialog and xmessage

if using GRASS's xmonitors you can replace those with d.menu + d.ask,
they are neat little under-utilized modules. But they will not be
ported to GRASS 7.



have fun,

Hamish



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the grass-user mailing list