[GRASS-user] Some questions about d.vect and d.rast

Hello GRASS community!

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?
2) How can I change the line type (e.g dashed line, etc.)?

I also want to use d.vect and d.rast in a python script after
some other calculations but the maps aren't displayed in the
running display-window.

I tried excactly:
grass.run_command("d.vect", map="points", display="shape,cat", color="red", icon="basic/pushpin", fcolor="red", size="10", attrcol="cat")
grass.run_command("d.vect", map="line", color="230:230:230")
grass.run_command("d.rast", map="raster")

and got following command console output:

PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: map.png,
GRASS_WIDTH=798, GRASS_HEIGHT=546
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: map.png,
GRASS_WIDTH=798, GRASS_HEIGHT=546
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: map.png,
GRASS_WIDTH=798, GRASS_HEIGHT=546

Is it possible to use these commands in a python script?

cheers
/Johannes

Johannes wrote:

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?

see
http://grass.osgeo.org/wiki/IconSymbols#Authoring_instructions

2) How can I change the line type (e.g dashed line, etc.)?

You can't. (only in ps.map)
Maybe it will be possible in grass7?

I also want to use d.vect and d.rast in a python script after
some other calculations but the maps aren't displayed in the
running display-window.

I'll leave that for others to answer.

Hamish

My way of using d.vect and d.rast in a python script is by first setting some variables and then using d.mon with the png driver:

os.putenv(GRASS_PNGFILE,'%s/%s.png' % (dirname,filename))
os.putenv(.....

grass.run_command('d.mon', start='PNG')
grass.run_command('d.rast',....
grass.run_command('d.vect',...
grass.run_command('d.mon', stop='PNG')

#If you want to display your map right away you could end your script with something like:

os.system(eog '%s/%s.png' % ((dirname,filename)) #linux eyes of gnome (eog)

Hope this helps.

Martin

-----Opprinnelig melding-----
Fra: grass-user-bounces@lists.osgeo.org [mailto:grass-user-bounces@lists.osgeo.org] På vegne av Hamish
Sendt: 29. april 2011 00:38
Til: grass-user@lists.osgeo.org; Johannes Radinger
Emne: Re: [GRASS-user] Some questions about d.vect and d.rast

Johannes wrote:

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?

see
http://grass.osgeo.org/wiki/IconSymbols#Authoring_instructions

2) How can I change the line type (e.g dashed line, etc.)?

You can't. (only in ps.map)
Maybe it will be possible in grass7?

I also want to use d.vect and d.rast in a python script after some
other calculations but the maps aren't displayed in the running
display-window.

I'll leave that for others to answer.

Hamish

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On 29/04/11 00:37, Hamish wrote:

Johannes wrote:

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?

see
  http://grass.osgeo.org/wiki/IconSymbols#Authoring_instructions

2) How can I change the line type (e.g dashed line, etc.)?

You can't. (only in ps.map)
Maybe it will be possible in grass7?

One possible option (although admittedly somewhat brute force) is to use v.to.points, playing with the dmax parameter in v.to.point or with the symbol size to differentiate.

You can only use symbols that are the same in all directions (e.g. circles) since the orientation of the symbol will not follow the orientation of the line.

See attached screenshots based on the North Carolina demo data roadsmajor map.

Moritz

(attachments)

different_dmax_same_symbol_size.png
same_dmax_different_symbol_size.png

On 29/04/11 11:34, Moritz Lennert wrote:

On 29/04/11 00:37, Hamish wrote:

Johannes wrote:

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?

see
http://grass.osgeo.org/wiki/IconSymbols#Authoring_instructions

2) How can I change the line type (e.g dashed line, etc.)?

You can't. (only in ps.map)
Maybe it will be possible in grass7?

One possible option (although admittedly somewhat brute force) is to use
v.to.points, playing with the dmax parameter in v.to.point or with the
symbol size to differentiate.

You can only use symbols that are the same in all directions (e.g.
circles) since the orientation of the symbol will not follow the
orientation of the line.

And more as proof-of-concept fun on Friday afternoon than anything serious (but who knows :slight_smile: ), here's a (convoluted) way to actually getting line patterns (using roadsmajor from NC demo data set) with d.vect:

#Split the lines into smaller segments to get more detailed azimuths
v.split roadsmajor out=temp length=100

#attach unique categories to each new line segment in layer 2, create table for layer 2 and retrieve whatever info is interesting from the original roads attribute table (in our case we'll only use MULTILANE)
v.category temp option=add layer=2 out=roads
v.db.addtable roads layer=2
v.db.addcol roads layer=2 col="multilane varchar(1)"
v.to.db roads layer=2 qlayer=1 option=query qcolumn=MULTILANE columns=multilane

#add columns for azimuth (CC from north) and aziumthccw (CCW from east) and fill them
v.db.addcol roads col="azimuth double precision" layer=2
v.db.addcol roads col="azimuthccw double precision" layer=2

v.to.db roads option=azimuth colu=azimuth layer=2
echo "update roads_2 set azimuthccw=450-azimuth where azimuth>90" | db.execute
echo "update roads_2 set azimuthccw=90-azimuth where azimuth<=90" | db.execute

#transform lines into points
v.to.points roads out=roadspoint dmax=100 llayer=2

#draw excerpt of the roads in a map with two linepatterns depending on multilane property

GRASS_RENDER_IMMEDIATE=TRUE
GRASS_HEIGHT=960
GRASS_WIDTH=1280

g.region n=233208 s=221687 w=624737 e=642078

d.vect roadspoint icon=linepatterns/line02 rot_column=azimuthccw where="multilane='n'"

export GRASS_PNG_READ=TRUE
d.vect roadspoint icon=linepatterns/line10 rot_column=azimuthccw where="multilane='y'"

And here are the symbols used

linepatterns/line02:

VERSION 1.0
BOX -0.5 -0.5 0.5 0.5
STRING
   LINE
      -0.1 0
      0.1 0
   END
END

linepatterns/line10:

VERSION 1.0
BOX -0.5 -0.5 0.5 0.5
STRING
   LINE
      -0.5 0
      0.5 0
   END
END

The result is shown on the attached map.

Enjoy your weekend !
:wink:

Moritz--
Institut de Gestion de l'Environnement et d'Aménagement du Territoire (IGEAT)
Université Libre de Bruxelles
Bvd du Triomphe, CP 246 (Campus Plaine)
1050 Bruxelles
Belgique

tél. + 32 2 650.56.16 / 50.72 (secr.)
fax + 32 2 650.50.92

(attachments)

linepatterns.png

Am 29.04.2011 um 16:05 schrieb Moritz Lennert:

On 29/04/11 11:34, Moritz Lennert wrote:

On 29/04/11 00:37, Hamish wrote:

Johannes wrote:

First I've two general questions about d.vect:
1) Is it possible to use own symbol for the point icons?

see
http://grass.osgeo.org/wiki/IconSymbols#Authoring_instructions

2) How can I change the line type (e.g dashed line, etc.)?

You can't. (only in ps.map)
Maybe it will be possible in grass7?

One possible option (although admittedly somewhat brute force) is to use
v.to.points, playing with the dmax parameter in v.to.point or with the
symbol size to differentiate.

You can only use symbols that are the same in all directions (e.g.
circles) since the orientation of the symbol will not follow the
orientation of the line.

And more as proof-of-concept fun on Friday afternoon than anything serious (but who knows :slight_smile: ), here's a (convoluted) way to actually getting line patterns (using roadsmajor from NC demo data set) with d.vect:

#Split the lines into smaller segments to get more detailed azimuths
v.split roadsmajor out=temp length=100

#attach unique categories to each new line segment in layer 2, create table for layer 2 and retrieve whatever info is interesting from the original roads attribute table (in our case we'll only use MULTILANE)
v.category temp option=add layer=2 out=roads
v.db.addtable roads layer=2
v.db.addcol roads layer=2 col="multilane varchar(1)"
v.to.db roads layer=2 qlayer=1 option=query qcolumn=MULTILANE columns=multilane

#add columns for azimuth (CC from north) and aziumthccw (CCW from east) and fill them
v.db.addcol roads col="azimuth double precision" layer=2
v.db.addcol roads col="azimuthccw double precision" layer=2

v.to.db roads option=azimuth colu=azimuth layer=2
echo "update roads_2 set azimuthccw=450-azimuth where azimuth>90" | db.execute
echo "update roads_2 set azimuthccw=90-azimuth where azimuth<=90" | db.execute

#transform lines into points
v.to.points roads out=roadspoint dmax=100 llayer=2

#draw excerpt of the roads in a map with two linepatterns depending on multilane property

GRASS_RENDER_IMMEDIATE=TRUE
GRASS_HEIGHT=960
GRASS_WIDTH=1280

g.region n=233208 s=221687 w=624737 e=642078

d.vect roadspoint icon=linepatterns/line02 rot_column=azimuthccw where="multilane='n'"

export GRASS_PNG_READ=TRUE
d.vect roadspoint icon=linepatterns/line10 rot_column=azimuthccw where="multilane='y'"

And here are the symbols used

linepatterns/line02:

VERSION 1.0
BOX -0.5 -0.5 0.5 0.5
STRING
LINE
    -0.1 0
    0.1 0
END
END

linepatterns/line10:

VERSION 1.0
BOX -0.5 -0.5 0.5 0.5
STRING
LINE
    -0.5 0
    0.5 0
END
END

The result is shown on the attached map.

Enjoy your weekend !
:wink:

Oh really nice, I like that work around. :slight_smile: Will test it this weekend but will also use ps.map.
Nice weekend as well!

/Johannes

Moritz--
Institut de Gestion de l'Environnement et d'Aménagement du Territoire (IGEAT)
Université Libre de Bruxelles
Bvd du Triomphe, CP 246 (Campus Plaine)
1050 Bruxelles
Belgique

tél. + 32 2 650.56.16 / 50.72 (secr.)
fax + 32 2 650.50.92
<linepatterns.png>_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user