[GRASS-dev] patch for v.voronoi/v.delaunay

Markus Neteler neteler at osgeo.org
Fri May 2 17:15:35 EDT 2008


On Wed, Apr 23, 2008 at 8:14 AM, Hamish <hamish_b at yahoo.com> wrote:
> Markus Neteler wrote:
> > I wonder if I could colorize the 3D TIN somehow using v.colors.
> > So far it does not have a DB connected.
>
...
> create a DB table for it with columns="int cat, GRASSRGB varchar(11)" and

v.db.addtable tin col="east double precision, north double precision, \
      height double precision, GRASSRGB varchar(11)"

[... not needed ... ]

> somehow for each triangle extract the 3 elev values (v.extract +
> v.out.ascii in a loop would work but probably there is a better way,
> maybe v.to.db or like v.what.vect). do either SQL magic or awk magic or
> ..?. to get an average value for the triangle

That's now automatically done with the recent 3D extentions to v.delaunay
(the Vect_tin_get_z() was sleeping for some years, now used).

> upload the mean to the centroid with v.db.update or similar, then run
> v.colors..

# transfer geometry for colorizing
v.to.db tin opt=coor col="east,north,height"
v.db.select tin

v.colors tin column=height rgb_column=GRASSRGB color=rainbow

Should work... but it fails due to a precision problem in the output
of v.db.select:


v.colors tin column=height rgb_column=GRASSRGB color=rainbow
...
Looking up colors ...
+ v.db.select map=tin layer=1 column=height
+ sort -n
+ grep '^[-0-9]'
+ uniq
+ r.what.color -i in=tmp_colr_22337
+ sed -e 's/: /|/'
+ grep -v '|\*$'
+ read LINE
++ echo '1.353553|255:255:0'
++ cut -f1 '-d|'
+ VALUE=1.353553
++ echo '1.353553|255:255:0'
++ cut -f2 '-d|'
+ COLR=255:255:0
+ echo 'UPDATE tin SET GRASSRGB = '\''255:255:0'\'' WHERE height = 1.353553;'
...

[ for comparison:
v.db.select output:
...
D3/3: fetch row = 4
D3/3: col 0, litetype 2, sqltype 6: val = '4.0'
D3/3: Row fetched
4
D3/3: fetch row = 5
D3/3: col 0, litetype 2, sqltype 6: val = '2.35355339059327'
D3/3: Row fetched
2.353553
...
]


sqlite3 /home/neteler/grassdata/eth_utm32/PERMANENT/sqlite.db
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> select * from tin;
1|3.53553390593274|6.46446609406726|1.35355339059327|
2|6.46446609406726|3.53553390593274|1.35355339059327|
3|13.5355339059327|6.46446609406726|2.64644660940673|
4|6.46446609406726|13.5355339059327|2.64644660940673|
5|16.4644660940673|3.53553390593274|2.06066017177982|
6|16.4644660940673|13.5355339059327|4.0|255:0:1
7|3.53553390593274|16.4644660940673|2.35355339059327|
8|13.5355339059327|16.4644660940673|4.0|255:0:1
sqlite>

Should we fix the v.db.select output (new flag for full precision output)?

Markus


More information about the grass-dev mailing list