[GRASS-user] Creating a png file with multiple vector maps

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r
Chris

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user <grass-user@lists.osgeo.org> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r
Chris


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

Hi Anna - thank you for the suggestion - I tried it but alas, still it only outputs a single vector map (layer). I can get either the Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová kratochanna@gmail.com wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user <grass-user@lists.osgeo.org> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r

Chris


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

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still it only outputs a single vector map (layer). I can get either the Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that might cause some issues, you use one or the other. So try to remove the lines starting with d.mon.

Hope that helps,
Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user <grass-user@lists.osgeo.org> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r

Chris


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

Good morning Anna,
It took quite a while of trial and error but I worked out a method that kindof works:
First off - unless someone says otherwise, you can’t use the PNG driver (d.mon) method to overlay more than one polygon vector. Sorry - it just doesn’t work. You CAN use the ps.map method - that works really well generating the image however it by default assumes you are printing on an A4 piece of paper so there’s all sorts of white space. The image is centered at the top of this fictional piece of paper. In your postscript rules file you can use the “maploc” command to position the image elsewhere on the page. This is necessary because the next trick changes the paper dimensions but it assumes the origin is the lower left corner and therefore clips anything that is above the new dimensions. Back to postscript commands in the rules file first though … the ps.map maploc command uses inches (why?? it should be points) so an A4 page is 8.27" x 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a default 36p margin (0.5 inch). You’ll need those numbers later. maploc also lets you set the size of your image box: maploc {x offset from left edge} {y offset from top} {width of box} {height of box} Note: this is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the bottom of the page

note that if you push it too far down to where the box would run off the bottom, the image is

resized to fit on the page so do some testing to come up with the correct values

also I found the computational region controls the aspect ratio so although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.

border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276 -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c “<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining (http://www.ghostscript.com/doc/9.27/Use.htm) but in a nutshell, the parameters to play with are first the Pageoffset [x y] values. They are in points not inches … 1/72 inch = 1 point … remember the 1/2" margins? the -34 gives me 2 points of white space to the left edge of the map frame, the 78 I had to play with to push the map frame down to the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in points … this “trims” the paper to height and width … set something then run it and view the results. Adjust and run again until you get it correct.

It’s a royal pain but it seems to work this way. It would sure be nice to create a GRASS workspace file and just say “convert this workspace to an image” with everything all laid out nicely - like Arc does exporting their mxd map files…

I hope this helps someone !
:slight_smile:

Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová kratochanna@gmail.com wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still it only outputs a single vector map (layer). I can get either the Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that might cause some issues, you use one or the other. So try to remove the lines starting with d.mon.

Hope that helps,

Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user <grass-user@lists.osgeo.org> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r

Chris


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

Would this addon be useful? https://grass.osgeo.org/grass78/manuals/addons/m.printws.html

On February 11, 2021 6:55:24 PM Chris Bartolomei via grass-user grass-user@lists.osgeo.org wrote:

Good morning Anna,
It took quite a while of trial and error but I worked out a method that kindof works:
First off - unless someone says otherwise, you can’t use the PNG driver (d.mon) method to overlay more than one polygon vector. Sorry - it just doesn’t work. You CAN use the ps.map method - that works really well generating the image however it by default assumes you are printing on an A4 piece of paper so there’s all sorts of white space. The image is centered at the top of this fictional piece of paper. In your postscript rules file you can use the “maploc” command to position the image elsewhere on the page. This is necessary because the next trick changes the paper dimensions but it assumes the origin is the lower left corner and therefore clips anything that is above the new dimensions. Back to postscript commands in the rules file first though … the ps.map maploc command uses inches (why?? it should be points) so an A4 page is 8.27" x 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a default 36p margin (0.5 inch). You’ll need those numbers later. maploc also lets you set the size of your image box: maploc {x offset from left edge} {y offset from top} {width of box} {height of box} Note: this is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the bottom of the page

note that if you push it too far down to where the box would run off the bottom, the image is

resized to fit on the page so do some testing to come up with the correct values

also I found the computational region controls the aspect ratio so although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.

border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276 -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c “<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining (http://www.ghostscript.com/doc/9.27/Use.htm) but in a nutshell, the parameters to play with are first the Pageoffset [x y] values. They are in points not inches … 1/72 inch = 1 point … remember the 1/2" margins? the -34 gives me 2 points of white space to the left edge of the map frame, the 78 I had to play with to push the map frame down to the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in points … this “trims” the paper to height and width … set something then run it and view the results. Adjust and run again until you get it correct.

It’s a royal pain but it seems to work this way. It would sure be nice to create a GRASS workspace file and just say “convert this workspace to an image” with everything all laid out nicely - like Arc does exporting their mxd map files…

I hope this helps someone !
:slight_smile:

Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová kratochanna@gmail.com wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still it only outputs a single vector map (layer). I can get either the Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that might cause some issues, you use one or the other. So try to remove the lines starting with d.mon.

Hope that helps,

Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user <grass-user@lists.osgeo.org> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have command-line capability. I have two vector layers (a country boundary polygon and part of an administrative area map - also polygons). I am trying to automate creating a PNG file of the admin areas overlaying the country boundary therefore all work has to be command-line (in a bash script). I’ve tried this two ways - using the d.mon start=png method and also the ps.map method as described below. The d.mon method appears to generate the image with only one vector map (not both) and only colors the borders - it won’t use the fill_color setting. The ps.map method seems to work but assumes the image is on a sheet of paper so there’s a ton of extra white-space. I’d like to use d.mon but I can use ps.map if someone could please let me know how to export only the computational region without all the extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153 display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map is converted to png however it DOES do the color fill properly. With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps --overwrite

where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png $HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white margins and a lot of white space below the image like it is printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple vector maps overlaying each other (and not have the extra whitespace too)?

v/r

Chris


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


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

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5) and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT fill_color=none
d.vect map=roadsmajor@PERMANENT color=255:0:0:255
d.vect map=schools_wake@PERMANENT fill_color=0:128:0:255 icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:

Good morning Anna,
It took quite a while of trial and error but I worked out a method that kindof works:
First off - unless someone says otherwise, you can't use the PNG driver (d.mon) method to overlay more than one polygon vector. Sorry - it just doesn't work. You CAN use the ps.map method - that works really well generating the image however it by default assumes you are printing on an A4 piece of paper so there's all sorts of white space. The image is centered at the top of this fictional piece of paper. In your postscript rules file you can use the "maploc" command to position the image elsewhere on the page. This is necessary because the next trick changes the paper dimensions but it assumes the origin is the lower left corner and therefore clips anything that is above the new dimensions. Back to postscript commands in the rules file first though ... the ps.map maploc command uses inches (why?? it should be points) so an A4 page is 8.27" x 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a default 36p margin (0.5 inch). You'll need those numbers later. maploc also lets you set the size of your image box: maploc {x offset from left edge} {y offset from top} {width of box} {height of box} Note: this is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the bottom of the page
# note that if you push it too far down to where the box would run off the bottom, the image is
# resized to fit on the page so do some testing to come up with the correct values
# also I found the computational region controls the aspect ratio so although I say
# 6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.
border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here's the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276 -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c "<</PageOffset [-34 78]>> setpagedevice" -f $HOME/color_admin.ps

So the above line needs some explaining (http://www.ghostscript.com/doc/9.27/Use.htm) but in a nutshell, the parameters to play with are first the Pageoffset [x y] values. They are in points not inches ... 1/72 inch = 1 point ... remember the 1/2" margins? the -34 gives me 2 points of white space to the left edge of the map frame, the 78 I had to play with to push the map frame down to the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS ... again in points ... this "trims" the paper to height and width ... set something then run it and view the results. Adjust and run again until you get it correct.

It's a royal pain but it seems to work this way. It would sure be nice to create a GRASS workspace file and just say "convert this workspace to an image" with everything all laid out nicely - like Arc does exporting their mxd map files...

I hope this helps someone !
:slight_smile:
Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová <kratochanna@gmail.com> wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>> wrote:

    Hi Anna - thank you for the suggestion - I tried it but alas, still
    it only outputs a single vector map (layer). I can get either the
    Country vector or the admin_areas vector, but not both overlaid.
    :(
    Chris

I realized you are using both environmental variables and d.mon, that might cause some issues, you use one or the other. So try to remove the lines starting with d.mon.

Hope that helps,
Anna

    On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
    <kratochanna@gmail.com <mailto:kratochanna@gmail.com>> wrote:

    Hi,

    On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
    <grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>> wrote:

        Good morning :slight_smile:
        I'm using GRASS 7.4.1 on a Linux cluster so I only have
        command-line capability. I have two vector layers (a country
        boundary polygon and part of an administrative area map - also
        polygons). I am trying to automate creating a PNG file of the
        admin areas overlaying the country boundary therefore all work
        has to be command-line (in a bash script). I've tried this two
        ways - using the d.mon start=png method and also the ps.map
        method as described below. The d.mon method appears to generate
        the image with only one vector map (not both) and only colors
        the borders - it won't use the fill_color setting. The ps.map
        method seems to work but assumes the image is on a sheet of
        paper so there's a ton of extra white-space. I'd like to use
        d.mon but I can use ps.map if someone could please let me know
        how to export only the computational region without all the
        extra 'paper' in the image. Here's my code:

        g.region vector='Country'
        export GRASS_RENDER_IMMEDIATE=png
        export GRASS_RENDER_WIDTH=640
        export GRASS_RENDER_HEIGHT=480
        export GRASS_RENDER_TRANSPARENT=true
        export GRASS_RENDER_TRUECOLOR=true
        export GRASS_RENDER_FILE=$HOME/country_admin.png
        export GRASS_RENDER_FILE_COMPRESSION=0
        export GRASS_MESSAGE_FORMAT=plain
        d.mon start=png
        d.vect map=Country color=210:210:210 fill_color=153:153:153
        display=shape type=area
        d.vect map=admin_area color=153:153:153 rgb_column=area_color
        display=shape type=area
        d.mon stop=png

        This only produces a png with the last vector listed and only
        the borders are colored with the rgb_column values.

    I think you are missing GRASS_RENDER_FILE_READ=TRUE:
    https://grass.osgeo.org/grass78/manuals/pngdriver.html
    <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;

    Regarding rgb_column, I am not sure, didn't have time to test.

    Anna

        If I do this without the d.mon start/stop lines ... i.e. relying
        on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
        is converted to png however it DOES do the color fill properly.
        With either above method the png is the correct size.

        Now using ps.map (same env variable set as above):

        g.region vector='Country'
        ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
        --overwrite
          where ps_rules.txt is:
        border y
          color 81:81:81
          end
        vareas admin_area
          layer 1
          rgbcolumn area_color
          color 153:153:153
          end
        vareas Country
          color 210:210:210
          fcolor 153:153:153
          end

        We don't have pstopng but we do have ghostscript:

        gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
        -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
        $HOME/country_admin.ps

        This creates the correct image (color fills, etc) but has white
        margins and a lot of white space below the image likeit is
        printed at the top of a piece of paper.

        does anyone have any idea how to create a png with multiple
        vector maps overlaying each other (and not have the extra
        whitespace too)?

        v/r
        Chris

        _______________________________________________
        grass-user mailing list
        grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
        https://lists.osgeo.org/mailman/listinfo/grass-user
        <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;

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

(attachments)

test_small.png

Mortiz - are those vector layers areas ? I’m guessing the census is an area, the roads are lines and the schools are points, yes? I’m having an issue overlaying two area maps (polygons). i can only get one to show … I have tried your method with all the export GRASS_RENDER* variables but I have a country polygon map as the bottom later and a selection of a few administrative areas (provinces/states) as the top map and I can only get one or the other to show up. It almost seems as if the transparency doesn’t work and what should be transparent in the admin map is actually the background color and blocks the country from being seen.
Could you please try your method with a couple area (polygon) vector maps overlaying each other?
Thanks!
:slight_smile:

Chris

On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert mlennert@club.worldonline.be wrote:

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5)
and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT fill_color=none
d.vect map=roadsmajor@PERMANENT color=255:0:0:255
d.vect map=schools_wake@PERMANENT fill_color=0:128:0:255
icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:

Good morning Anna,
It took quite a while of trial and error but I worked out a method that
kindof works:
First off - unless someone says otherwise, you can’t use the PNG driver
(d.mon) method to overlay more than one polygon vector. Sorry - it just
doesn’t work. You CAN use the ps.map method - that works really well
generating the image however it by default assumes you are printing on
an A4 piece of paper so there’s all sorts of white space. The image is
centered at the top of this fictional piece of paper. In your postscript
rules file you can use the “maploc” command to position the image
elsewhere on the page. This is necessary because the next trick changes
the paper dimensions but it assumes the origin is the lower left corner
and therefore clips anything that is above the new dimensions. Back to
postscript commands in the rules file first though … the ps.map maploc
command uses inches (why?? it should be points) so an A4 page is 8.27" x
11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
default 36p margin (0.5 inch). You’ll need those numbers later. maploc
also lets you set the size of your image box: maploc {x offset from
left edge} {y offset from top} {width of box} {height of box} Note: this
is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
bottom of the page

note that if you push it too far down to where the box would run off

the bottom, the image is

resized to fit on the page so do some testing to come up with the

correct values

also I found the computational region controls the aspect ratio so

although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.

border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill
the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are
other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
-dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
“<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining
(http://www.ghostscript.com/doc/9.27/Use.htm) but in a nutshell, the
parameters to play with are first the Pageoffset [x y] values. They are
in points not inches … 1/72 inch = 1 point … remember the 1/2"
margins? the -34 gives me 2 points of white space to the left edge of
the map frame, the 78 I had to play with to push the map frame down to
the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in points
… this “trims” the paper to height and width … set something then
run it and view the results. Adjust and run again until you get it correct.

It’s a royal pain but it seems to work this way. It would sure be nice
to create a GRASS workspace file and just say “convert this workspace to
an image” with everything all laid out nicely - like Arc does exporting
their mxd map files…

I hope this helps someone !
:slight_smile:
Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
<kratochanna@gmail.com> wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com
mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still
it only outputs a single vector map (layer). I can get either the
Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that
might cause some issues, you use one or the other. So try to remove the
lines starting with d.mon.

Hope that helps,
Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
<grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)> wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have
command-line capability. I have two vector layers (a country
boundary polygon and part of an administrative area map - also
polygons). I am trying to automate creating a PNG file of the
admin areas overlaying the country boundary therefore all work
has to be command-line (in a bash script). I’ve tried this two
ways - using the d.mon start=png method and also the ps.map
method as described below. The d.mon method appears to generate
the image with only one vector map (not both) and only colors
the borders - it won’t use the fill_color setting. The ps.map
method seems to work but assumes the image is on a sheet of
paper so there’s a ton of extra white-space. I’d like to use
d.mon but I can use ps.map if someone could please let me know
how to export only the computational region without all the
extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153
display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color
display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only
the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html
<https://grass.osgeo.org/grass78/manuals/pngdriver.html>

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying
on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
is converted to png however it DOES do the color fill properly.
With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’
ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
–overwrite
where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
$HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white
margins and a lot of white space below the image likeit is
printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple
vector maps overlaying each other (and not have the extra
whitespace too)?

v/r
Chris


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>


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

On 16/02/21 15:54, Chris Bartolomei wrote:

Mortiz - are those vector layers areas ? I'm guessing the census is an area, the roads are lines and the schools are points, yes? I'm having an issue overlaying two area maps (polygons). i can only get one to show ... I have tried your method with all the export GRASS_RENDER* variables but I have a country polygon map as the bottom later and a selection of a few administrative areas (provinces/states) as the top map and I can only get one or the other to show up. It almost seems as if the transparency doesn't work and what should be transparent in the admin map is actually the background color and blocks the country from being seen.
Could you please try your method with a couple area (polygon) vector maps overlaying each other?

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE
export GRASS_RENDER_FILE=$HOME/test.png

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT fill_color=grey
d.vect map=censusblk_swwake@PERMANENT fill_color=red

I've tried with

export GRASS_RENDER_TRANSPARENT=TRUE
and
export GRASS_RENDER_TRANSPARENT=FALSE

As you can see in the attached images, the overlay seems to work without any issues (or I don't understand what you are looking for exactly) and setting GRASS_RENDER_TRANSPARENT decides on whether the background should be transparent or not.

A second test in the same data set, but with different layers:

export GRASS_RENDER_TRANSPARENT=TRUE
export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

export GRASS_RENDER_TRANSPARENT=FALSE
export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

Again, the overlay works, at least as I would have expected.

Moritz

On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5)
and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT <mailto:census_wake2000@PERMANENT> fill_color=none
d.vect map=roadsmajor@PERMANENT <mailto:roadsmajor@PERMANENT> color=255:0:0:255
d.vect map=schools_wake@PERMANENT <mailto:schools_wake@PERMANENT> fill_color=0:128:0:255
icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:
> Good morning Anna,
> It took quite a while of trial and error but I worked out a method that
> kindof works:
> First off - unless someone says otherwise, you can't use the PNG driver
> (d.mon) method to overlay more than one polygon vector. Sorry - it just
> doesn't work. You CAN use the ps.map method - that works really well
> generating the image however it by default assumes you are printing on
> an A4 piece of paper so there's all sorts of white space. The image is
> centered at the top of this fictional piece of paper. In your postscript
> rules file you can use the "maploc" command to position the image
> elsewhere on the page. This is necessary because the next trick changes
> the paper dimensions but it assumes the origin is the lower left corner
> and therefore clips anything that is above the new dimensions. Back to
> postscript commands in the rules file first though ... the ps.map maploc
> command uses inches (why?? it should be points) so an A4 page is 8.27" x
> 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
> default 36p margin (0.5 inch). You'll need those numbers later. maploc
> also lets you set the size of your image box: maploc {x offset from
> left edge} {y offset from top} {width of box} {height of box} Note: this
> is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
> python. This is my postscript rules file:
>
> maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
> bottom of the page
> # note that if you push it too far down to where the box would run off
> the bottom, the image is
> # resized to fit on the page so do some testing to come up with the
> correct values
> # also I found the computational region controls the aspect ratio so
> although I say
> # 6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.
> border y # add a border to the map frame (box)
> color 81:81:81 # shade of gray
> end # end the border controls
> vareas admin_area # top vector layer to display
> layer 1 # attribute table to use
> rgbcolumn area_color # name of column holding R:G:B values to fill
> the polygons
> color 153:153:153 #boundary color
> end # end the admin_area controls
> vareas Country # this is the bottom vectors to display
> color 210:210:210 #boundary color
> fcolor 153:153:153 #fill color for all polygons
> end # end the Country controls
>
> Here's the command to run to generate the postscript file:
>
> ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite
>
> To convert the postscript to PNG I had to use ghostscript - there are
> other tools you can use though.
>
> gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
> -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
> -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
> "<</PageOffset [-34 78]>> setpagedevice" -f $HOME/color_admin.ps
>
> So the above line needs some explaining
> (http://www.ghostscript.com/doc/9.27/Use.htm) but in a nutshell, the
> parameters to play with are first the Pageoffset [x y] values. They are
> in points not inches ... 1/72 inch = 1 point ... remember the 1/2"
> margins? the -34 gives me 2 points of white space to the left edge of
> the map frame, the 78 I had to play with to push the map frame down to
> the right spot.
> Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS ... again in points
> ... this "trims" the paper to height and width ... set something then
> run it and view the results. Adjust and run again until you get it correct.
>
> It's a royal pain but it seems to work this way. It would sure be nice
> to create a GRASS workspace file and just say "convert this workspace to
> an image" with everything all laid out nicely - like Arc does exporting
> their mxd map files...
>
> I hope this helps someone !
> :slight_smile:
> Chris
>
> On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
> <kratochanna@gmail.com <mailto:kratochanna@gmail.com>> wrote:
>
> On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>
> <mailto:surfcjb@yahoo.com>> wrote:
>
> Hi Anna - thank you for the suggestion - I tried it but alas, still
> it only outputs a single vector map (layer). I can get either the
> Country vector or the admin_areas vector, but not both overlaid.
> :frowning:
> Chris
>
> I realized you are using both environmental variables and d.mon, that
> might cause some issues, you use one or the other. So try to remove the
> lines starting with d.mon.
>
> Hope that helps,
> Anna
>
> On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
> <kratochanna@gmail.com <mailto:kratochanna@gmail.com> <mailto:kratochanna@gmail.com>> wrote:
>
> Hi,
>
> On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
> <grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>> wrote:
>
> Good morning :slight_smile:
> I'm using GRASS 7.4.1 on a Linux cluster so I only have
> command-line capability. I have two vector layers (a country
> boundary polygon and part of an administrative area map - also
> polygons). I am trying to automate creating a PNG file of the
> admin areas overlaying the country boundary therefore all work
> has to be command-line (in a bash script). I've tried this two
> ways - using the d.mon start=png method and also the ps.map
> method as described below. The d.mon method appears to generate
> the image with only one vector map (not both) and only colors
> the borders - it won't use the fill_color setting. The ps.map
> method seems to work but assumes the image is on a sheet of
> paper so there's a ton of extra white-space. I'd like to use
> d.mon but I can use ps.map if someone could please let me know
> how to export only the computational region without all the
> extra 'paper' in the image. Here's my code:
>
> g.region vector='Country'
> export GRASS_RENDER_IMMEDIATE=png
> export GRASS_RENDER_WIDTH=640
> export GRASS_RENDER_HEIGHT=480
> export GRASS_RENDER_TRANSPARENT=true
> export GRASS_RENDER_TRUECOLOR=true
> export GRASS_RENDER_FILE=$HOME/country_admin.png
> export GRASS_RENDER_FILE_COMPRESSION=0
> export GRASS_MESSAGE_FORMAT=plain
> d.mon start=png
> d.vect map=Country color=210:210:210 fill_color=153:153:153
> display=shape type=area
> d.vect map=admin_area color=153:153:153 rgb_column=area_color
> display=shape type=area
> d.mon stop=png
>
> This only produces a png with the last vector listed and only
> the borders are colored with the rgb_column values.
>
> I think you are missing GRASS_RENDER_FILE_READ=TRUE:
> https://grass.osgeo.org/grass78/manuals/pngdriver.html
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;
>
> Regarding rgb_column, I am not sure, didn't have time to test.
>
> Anna
>
> If I do this without the d.mon start/stop lines ... i.e. relying
> on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
> is converted to png however it DOES do the color fill properly.
> With either above method the png is the correct size.
>
> Now using ps.map (same env variable set as above):
>
> g.region vector='Country'
> ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
> --overwrite
> where ps_rules.txt is:
> border y
> color 81:81:81
> end
> vareas admin_area
> layer 1
> rgbcolumn area_color
> color 153:153:153
> end
> vareas Country
> color 210:210:210
> fcolor 153:153:153
> end
>
> We don't have pstopng but we do have ghostscript:
>
> gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
> -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
> $HOME/country_admin.ps
>
> This creates the correct image (color fills, etc) but has white
> margins and a lot of white space below the image likeit is
> printed at the top of a piece of paper.
>
> does anyone have any idea how to create a png with multiple
> vector maps overlaying each other (and not have the extra
> whitespace too)?
>
> v/r
> Chris
>
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> https://lists.osgeo.org/mailman/listinfo/grass-user
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;

>
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
> https://lists.osgeo.org/mailman/listinfo/grass-user
>

(attachments)

test_small_FALSE.png
test_small_TRUE.png
test_NC_TRUE_small.png
test_NC_FALSE_small.png

Well - that does indeed work for you. I’ll try your settings when I get into the office - we’re running GRASS on a RHEL 7 cluster - and see what I can come up with.
It would be sooo much better if it worked like yours did!
Thank you so much for taking the time and testing this out
:slight_smile:
v/r
Chris

On Tuesday, February 16, 2021, 11:07:10 AM EST, Moritz Lennert mlennert@club.worldonline.be wrote:

On 16/02/21 15:54, Chris Bartolomei wrote:

Mortiz - are those vector layers areas ? I’m guessing the census is an
area, the roads are lines and the schools are points, yes? I’m having
an issue overlaying two area maps (polygons). i can only get one to show
… I have tried your method with all the export GRASS_RENDER* variables
but I have a country polygon map as the bottom later and a selection of
a few administrative areas (provinces/states) as the top map and I can
only get one or the other to show up. It almost seems as if the
transparency doesn’t work and what should be transparent in the admin
map is actually the background color and blocks the country from being seen.
Could you please try your method with a couple area (polygon) vector
maps overlaying each other?

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE
export GRASS_RENDER_FILE=$HOME/test.png

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT fill_color=grey
d.vect map=censusblk_swwake@PERMANENT fill_color=red

I’ve tried with

export GRASS_RENDER_TRANSPARENT=TRUE
and
export GRASS_RENDER_TRANSPARENT=FALSE

As you can see in the attached images, the overlay seems to work without
any issues (or I don’t understand what you are looking for exactly) and
setting GRASS_RENDER_TRANSPARENT decides on whether the background
should be transparent or not.

A second test in the same data set, but with different layers:

export GRASS_RENDER_TRANSPARENT=TRUE
export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

export GRASS_RENDER_TRANSPARENT=FALSE
export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

Again, the overlay works, at least as I would have expected.

Moritz

On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5)
and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT mailto:[census_wake2000@PERMANENT](mailto:census_wake2000@PERMANENT)
fill_color=none
d.vect map=roadsmajor@PERMANENT mailto:[roadsmajor@PERMANENT](mailto:roadsmajor@PERMANENT)
color=255:0:0:255
d.vect map=schools_wake@PERMANENT mailto:[schools_wake@PERMANENT](mailto:schools_wake@PERMANENT)
fill_color=0:128:0:255
icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:

Good morning Anna,
It took quite a while of trial and error but I worked out a method that
kindof works:
First off - unless someone says otherwise, you can’t use the PNG driver
(d.mon) method to overlay more than one polygon vector. Sorry - it just
doesn’t work. You CAN use the ps.map method - that works really well
generating the image however it by default assumes you are printing on
an A4 piece of paper so there’s all sorts of white space. The image is
centered at the top of this fictional piece of paper. In your postscript
rules file you can use the “maploc” command to position the image
elsewhere on the page. This is necessary because the next trick changes
the paper dimensions but it assumes the origin is the lower left corner
and therefore clips anything that is above the new dimensions. Back to
postscript commands in the rules file first though … the ps.map maploc
command uses inches (why?? it should be points) so an A4 page is 8.27" x
11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
default 36p margin (0.5 inch). You’ll need those numbers later. maploc
also lets you set the size of your image box: maploc {x offset from
left edge} {y offset from top} {width of box} {height of box} Note: this
is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
bottom of the page

note that if you push it too far down to where the box would run off

the bottom, the image is

resized to fit on the page so do some testing to come up with the

correct values

also I found the computational region controls the aspect ratio so

although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.

border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill
the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are
other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
-dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
“<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining
(http://www.ghostscript.com/doc/9.27/Use.htm
<http://www.ghostscript.com/doc/9.27/Use.htm>) but in a nutshell, the
parameters to play with are first the Pageoffset [x y] values. They are
in points not inches … 1/72 inch = 1 point … remember the 1/2"
margins? the -34 gives me 2 points of white space to the left edge of
the map frame, the 78 I had to play with to push the map frame down to
the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in points
… this “trims” the paper to height and width … set something then
run it and view the results. Adjust and run again until you get it
correct.

It’s a royal pain but it seems to work this way. It would sure be nice
to create a GRASS workspace file and just say “convert this workspace to
an image” with everything all laid out nicely - like Arc does exporting
their mxd map files…

I hope this helps someone !
:slight_smile:
Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)> wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com
mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)
<mailto:surfcjb@yahoo.com mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)>> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still
it only outputs a single vector map (layer). I can get either the
Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that
might cause some issues, you use one or the other. So try to remove the
lines starting with d.mon.

Hope that helps,
Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)
<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)>> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
<grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>>
wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have
command-line capability. I have two vector layers (a country
boundary polygon and part of an administrative area map - also
polygons). I am trying to automate creating a PNG file of the
admin areas overlaying the country boundary therefore all work
has to be command-line (in a bash script). I’ve tried this two
ways - using the d.mon start=png method and also the ps.map
method as described below. The d.mon method appears to generate
the image with only one vector map (not both) and only colors
the borders - it won’t use the fill_color setting. The ps.map
method seems to work but assumes the image is on a sheet of
paper so there’s a ton of extra white-space. I’d like to use
d.mon but I can use ps.map if someone could please let me know
how to export only the computational region without all the
extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153
display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color
display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only
the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html
<https://grass.osgeo.org/grass78/manuals/pngdriver.html>
<https://grass.osgeo.org/grass78/manuals/pngdriver.html
<https://grass.osgeo.org/grass78/manuals/pngdriver.html>>

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying
on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
is converted to png however it DOES do the color fill properly.
With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’
ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
–overwrite
where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
$HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white
margins and a lot of white space below the image likeit is
printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple
vector maps overlaying each other (and not have the extra
whitespace too)?

v/r
Chris


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>
https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>
<https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>>


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>

Ohhhhh !! Sooooooo close ! I can get the two vector maps to overlay and display but no matter what I do I cannot get them to do a color fill … ugh … fill_color does nothing. I can use “d.vect map=admin_area color=red” and the boundaries change to red, but “d.vect map=admin_area color=black fill_color=red” and i do not get any filled color. So frustrating. I thought maybe my shapefile imported as just a boundary but when I do a “v.category input=admin_area option=report” I get:
Layer/table 1/admin_area
type count min max
point 0 0 0

line 0 0 0
boundary 0 0 0
centroid 59 1 25
area 0 0 0
face 0 0 0
kernel 0 0 0
all 59 1 25

Should I have areas in there too ??
I wonder if the import went wonky… what is strange is that the ps.map tool fills the polygons just fine.

Moritz - could please I ask you to do a v.category on one of your vector maps (v.category input=censuslbk_wwake@PERMANENT option=report) and see if it has areas in it or just centroids like I have?

Thanks again for the help!
:slight_smile:

Chris

On Tuesday, February 16, 2021, 11:20:31 AM EST, Chris Bartolomei surfcjb@yahoo.com wrote:

Well - that does indeed work for you. I’ll try your settings when I get into the office - we’re running GRASS on a RHEL 7 cluster - and see what I can come up with.
It would be sooo much better if it worked like yours did!
Thank you so much for taking the time and testing this out
:slight_smile:
v/r
Chris

On Tuesday, February 16, 2021, 11:07:10 AM EST, Moritz Lennert mlennert@club.worldonline.be wrote:

On 16/02/21 15:54, Chris Bartolomei wrote:

Mortiz - are those vector layers areas ? I’m guessing the census is an
area, the roads are lines and the schools are points, yes? I’m having
an issue overlaying two area maps (polygons). i can only get one to show
… I have tried your method with all the export GRASS_RENDER* variables
but I have a country polygon map as the bottom later and a selection of
a few administrative areas (provinces/states) as the top map and I can
only get one or the other to show up. It almost seems as if the
transparency doesn’t work and what should be transparent in the admin
map is actually the background color and blocks the country from being seen.
Could you please try your method with a couple area (polygon) vector
maps overlaying each other?

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE
export GRASS_RENDER_FILE=$HOME/test.png

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT fill_color=grey
d.vect map=censusblk_swwake@PERMANENT fill_color=red

I’ve tried with

export GRASS_RENDER_TRANSPARENT=TRUE
and
export GRASS_RENDER_TRANSPARENT=FALSE

As you can see in the attached images, the overlay seems to work without
any issues (or I don’t understand what you are looking for exactly) and
setting GRASS_RENDER_TRANSPARENT decides on whether the background
should be transparent or not.

A second test in the same data set, but with different layers:

export GRASS_RENDER_TRANSPARENT=TRUE
export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

export GRASS_RENDER_TRANSPARENT=FALSE
export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT
d.vect map=boundary_municp@PERMANENT fill_color=255:255:0:255

Again, the overlay works, at least as I would have expected.

Moritz

On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5)
and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT mailto:[census_wake2000@PERMANENT](mailto:census_wake2000@PERMANENT)
fill_color=none
d.vect map=roadsmajor@PERMANENT mailto:[roadsmajor@PERMANENT](mailto:roadsmajor@PERMANENT)
color=255:0:0:255
d.vect map=schools_wake@PERMANENT mailto:[schools_wake@PERMANENT](mailto:schools_wake@PERMANENT)
fill_color=0:128:0:255
icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:

Good morning Anna,
It took quite a while of trial and error but I worked out a method that
kindof works:
First off - unless someone says otherwise, you can’t use the PNG driver
(d.mon) method to overlay more than one polygon vector. Sorry - it just
doesn’t work. You CAN use the ps.map method - that works really well
generating the image however it by default assumes you are printing on
an A4 piece of paper so there’s all sorts of white space. The image is
centered at the top of this fictional piece of paper. In your postscript
rules file you can use the “maploc” command to position the image
elsewhere on the page. This is necessary because the next trick changes
the paper dimensions but it assumes the origin is the lower left corner
and therefore clips anything that is above the new dimensions. Back to
postscript commands in the rules file first though … the ps.map maploc
command uses inches (why?? it should be points) so an A4 page is 8.27" x
11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
default 36p margin (0.5 inch). You’ll need those numbers later. maploc
also lets you set the size of your image box: maploc {x offset from
left edge} {y offset from top} {width of box} {height of box} Note: this
is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
bottom of the page

note that if you push it too far down to where the box would run off

the bottom, the image is

resized to fit on the page so do some testing to come up with the

correct values

also I found the computational region controls the aspect ratio so

although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.

border y # add a border to the map frame (box)
color 81:81:81 # shade of gray
end # end the border controls
vareas admin_area # top vector layer to display
layer 1 # attribute table to use
rgbcolumn area_color # name of column holding R:G:B values to fill
the polygons
color 153:153:153 #boundary color
end # end the admin_area controls
vareas Country # this is the bottom vectors to display
color 210:210:210 #boundary color
fcolor 153:153:153 #fill color for all polygons
end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are
other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
-dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
“<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining
(http://www.ghostscript.com/doc/9.27/Use.htm
<http://www.ghostscript.com/doc/9.27/Use.htm>) but in a nutshell, the
parameters to play with are first the Pageoffset [x y] values. They are
in points not inches … 1/72 inch = 1 point … remember the 1/2"
margins? the -34 gives me 2 points of white space to the left edge of
the map frame, the 78 I had to play with to push the map frame down to
the right spot.
Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in points
… this “trims” the paper to height and width … set something then
run it and view the results. Adjust and run again until you get it
correct.

It’s a royal pain but it seems to work this way. It would sure be nice
to create a GRASS workspace file and just say “convert this workspace to
an image” with everything all laid out nicely - like Arc does exporting
their mxd map files…

I hope this helps someone !
:slight_smile:
Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)> wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com
mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)
<mailto:surfcjb@yahoo.com mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)>> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still
it only outputs a single vector map (layer). I can get either the
Country vector or the admin_areas vector, but not both overlaid.
:frowning:
Chris

I realized you are using both environmental variables and d.mon, that
might cause some issues, you use one or the other. So try to remove the
lines starting with d.mon.

Hope that helps,
Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)
<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)>> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
<grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>>
wrote:

Good morning :slight_smile:
I’m using GRASS 7.4.1 on a Linux cluster so I only have
command-line capability. I have two vector layers (a country
boundary polygon and part of an administrative area map - also
polygons). I am trying to automate creating a PNG file of the
admin areas overlaying the country boundary therefore all work
has to be command-line (in a bash script). I’ve tried this two
ways - using the d.mon start=png method and also the ps.map
method as described below. The d.mon method appears to generate
the image with only one vector map (not both) and only colors
the borders - it won’t use the fill_color setting. The ps.map
method seems to work but assumes the image is on a sheet of
paper so there’s a ton of extra white-space. I’d like to use
d.mon but I can use ps.map if someone could please let me know
how to export only the computational region without all the
extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRANSPARENT=true
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE=$HOME/country_admin.png
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
d.mon start=png
d.vect map=Country color=210:210:210 fill_color=153:153:153
display=shape type=area
d.vect map=admin_area color=153:153:153 rgb_column=area_color
display=shape type=area
d.mon stop=png

This only produces a png with the last vector listed and only
the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:
https://grass.osgeo.org/grass78/manuals/pngdriver.html
<https://grass.osgeo.org/grass78/manuals/pngdriver.html>
<https://grass.osgeo.org/grass78/manuals/pngdriver.html
<https://grass.osgeo.org/grass78/manuals/pngdriver.html>>

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e. relying
on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
is converted to png however it DOES do the color fill properly.
With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’
ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
–overwrite
where ps_rules.txt is:
border y
color 81:81:81
end
vareas admin_area
layer 1
rgbcolumn area_color
color 153:153:153
end
vareas Country
color 210:210:210
fcolor 153:153:153
end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
-dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
$HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white
margins and a lot of white space below the image likeit is
printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple
vector maps overlaying each other (and not have the extra
whitespace too)?

v/r
Chris


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>
https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>
<https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>>


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
https://lists.osgeo.org/mailman/listinfo/grass-user
<https://lists.osgeo.org/mailman/listinfo/grass-user>

Hi Chris,

On 17/02/21 02:30, Chris Bartolomei wrote:

Ohhhhh !! Sooooooo close ! I can get the two vector maps to overlay and display but no matter what I do I cannot get them to do a color fill ... ugh ... fill_color does nothing. I can use "d.vect map=admin_area color=red" and the boundaries change to red, but "d.vect map=admin_area color=black fill_color=red" and i do not get any filled color. So frustrating. I thought maybe my shapefile imported as just a boundary but when I do a "v.category input=admin_area option=report" I get:
Layer/table 1/admin_area
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 59 1 25
area 0 0 0
face 0 0 0
kernel 0 0 0
all 59 1 25

Should I have areas in there too ??

I'm not really sure what 'area' in the output of v.category actually refers to, as areas cannot have categories in GRASS GIS.

In order to see if you have areas in your file, check with v.info:

I wonder if the import went wonky.... what is strange is that the ps.map tool fills the polygons just fine.
Moritz - could please I ask you to do a v.category on one of your vector maps (v.category input=censuslbk_wwake@PERMANENT option=report) and see if it has areas in it or just centroids like I have?

GRASS 7.8.5 (nc_spm_08_grass7):~ > v.info -t boundary_county
nodes=1114
points=0
lines=0
boundaries=1910
centroids=926
areas=926
islands=130
primitives=2836
map3d=0

but

>v.category boundary_county op=report
Layer/table: 1/boundary_county
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 926 1 926
area 0 0 0
face 0 0 0
kernel 0 0 0
all 926 1 926

In order to find out if the issue comes from your data or from your installation of GRASS GIS, you can also download the NC demo data set from https://grass.osgeo.org/download/data/#NorthCarolinaDataset and try to reproduce what I did in order to see if it works.

Moritz

On Tuesday, February 16, 2021, 11:20:31 AM EST, Chris Bartolomei <surfcjb@yahoo.com> wrote:

Well - that does indeed work for you. I'll try your settings when I get into the office - we're running GRASS on a RHEL 7 cluster - and see what I can come up with.
It would be sooo much better if it worked like yours did!
Thank you so much for taking the time and testing this out
:slight_smile:
v/r
Chris

On Tuesday, February 16, 2021, 11:07:10 AM EST, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 16/02/21 15:54, Chris Bartolomei wrote:
> Mortiz - are those vector layers areas ? I'm guessing the census is an
> area, the roads are lines and the schools are points, yes? I'm having
> an issue overlaying two area maps (polygons). i can only get one to show
> ... I have tried your method with all the export GRASS_RENDER* variables
> but I have a country polygon map as the bottom later and a selection of
> a few administrative areas (provinces/states) as the top map and I can
> only get one or the other to show up. It almost seems as if the
> transparency doesn't work and what should be transparent in the admin
> map is actually the background color and blocks the country from being seen.
> Could you please try your method with a couple area (polygon) vector
> maps overlaying each other?

export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_WIDTH=640
export GRASS_RENDER_HEIGHT=480
export GRASS_RENDER_TRUECOLOR=true
export GRASS_RENDER_FILE_COMPRESSION=0
export GRASS_MESSAGE_FORMAT=plain
export GRASS_RENDER_FILE_READ=TRUE
export GRASS_RENDER_FILE=$HOME/test.png

g.region vect=census_wake2000
d.vect map=census_wake2000@PERMANENT <mailto:census_wake2000@PERMANENT> fill_color=grey
d.vect map=censusblk_swwake@PERMANENT <mailto:censusblk_swwake@PERMANENT> fill_color=red

I've tried with

export GRASS_RENDER_TRANSPARENT=TRUE
and
export GRASS_RENDER_TRANSPARENT=FALSE

As you can see in the attached images, the overlay seems to work without
any issues (or I don't understand what you are looking for exactly) and
setting GRASS_RENDER_TRANSPARENT decides on whether the background
should be transparent or not.

A second test in the same data set, but with different layers:

export GRASS_RENDER_TRANSPARENT=TRUE
export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT <mailto:boundary_county@PERMANENT>
d.vect map=boundary_municp@PERMANENT <mailto:boundary_municp@PERMANENT> fill_color=255:255:0:255

export GRASS_RENDER_TRANSPARENT=FALSE
export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png
g.region vect=boundary_county
d.vect map=boundary_county@PERMANENT <mailto:boundary_county@PERMANENT>
d.vect map=boundary_municp@PERMANENT <mailto:boundary_municp@PERMANENT> fill_color=255:255:0:255

Again, the overlay works, at least as I would have expected.

Moritz

> On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert
> <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:
>
> Hi Chris,
>
> For me, the following works with the current stable GRASS GIS (7.8.5)
> and using maps from the NC demo data set:
>
> export GRASS_RENDER_IMMEDIATE=png
> export GRASS_RENDER_WIDTH=640
> export GRASS_RENDER_HEIGHT=480
> export GRASS_RENDER_TRANSPARENT=true
> export GRASS_RENDER_TRUECOLOR=true
> export GRASS_RENDER_FILE_COMPRESSION=0
> export GRASS_MESSAGE_FORMAT=plain
> export GRASS_RENDER_FILE_READ=TRUE
>
> g.region vect=census_wake2000
> d.vect map=census_wake2000@PERMANENT <mailto:census_wake2000@PERMANENT> <mailto:census_wake2000@PERMANENT>
> fill_color=none
> d.vect map=roadsmajor@PERMANENT <mailto:roadsmajor@PERMANENT> <mailto:roadsmajor@PERMANENT>
> color=255:0:0:255
> d.vect map=schools_wake@PERMANENT <mailto:schools_wake@PERMANENT> <mailto:schools_wake@PERMANENT>
> fill_color=0:128:0:255
> icon=basic/circle size=10
>
> I attach a small thumbnail of the resulting PNG file.
>
> Moritz
>
> On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:
> > Good morning Anna,
> > It took quite a while of trial and error but I worked out a method that
> > kindof works:
> > First off - unless someone says otherwise, you can't use the PNG driver
> > (d.mon) method to overlay more than one polygon vector. Sorry - it just
> > doesn't work. You CAN use the ps.map method - that works really well
> > generating the image however it by default assumes you are printing on
> > an A4 piece of paper so there's all sorts of white space. The image is
> > centered at the top of this fictional piece of paper. In your postscript
> > rules file you can use the "maploc" command to position the image
> > elsewhere on the page. This is necessary because the next trick changes
> > the paper dimensions but it assumes the origin is the lower left corner
> > and therefore clips anything that is above the new dimensions. Back to
> > postscript commands in the rules file first though ... the ps.map maploc
> > command uses inches (why?? it should be points) so an A4 page is 8.27" x
> > 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
> > default 36p margin (0.5 inch). You'll need those numbers later. maploc
> > also lets you set the size of your image box: maploc {x offset from
> > left edge} {y offset from top} {width of box} {height of box} Note: this
> > is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
> > python. This is my postscript rules file:
> >
> > maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
> > bottom of the page
> > # note that if you push it too far down to where the box would run off
> > the bottom, the image is
> > # resized to fit on the page so do some testing to come up with the
> > correct values
> > # also I found the computational region controls the aspect ratio so
> > although I say
> > # 6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8 inch box.
> > border y # add a border to the map frame (box)
> > color 81:81:81 # shade of gray
> > end # end the border controls
> > vareas admin_area # top vector layer to display
> > layer 1 # attribute table to use
> > rgbcolumn area_color # name of column holding R:G:B values to fill
> > the polygons
> > color 153:153:153 #boundary color
> > end # end the admin_area controls
> > vareas Country # this is the bottom vectors to display
> > color 210:210:210 #boundary color
> > fcolor 153:153:153 #fill color for all polygons
> > end # end the Country controls
> >
> > Here's the command to run to generate the postscript file:
> >
> > ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite
> >
> > To convert the postscript to PNG I had to use ghostscript - there are
> > other tools you can use though.
> >
> > gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
> > -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
> > -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
> > "<</PageOffset [-34 78]>> setpagedevice" -f $HOME/color_admin.ps
> >
> > So the above line needs some explaining
> > (http://www.ghostscript.com/doc/9.27/Use.htm >
> <http://www.ghostscript.com/doc/9.27/Use.htm&gt;\) but in a nutshell, the
> > parameters to play with are first the Pageoffset [x y] values. They are
> > in points not inches ... 1/72 inch = 1 point ... remember the 1/2"
> > margins? the -34 gives me 2 points of white space to the left edge of
> > the map frame, the 78 I had to play with to push the map frame down to
> > the right spot.
> > Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS ... again in points
> > ... this "trims" the paper to height and width ... set something then
> > run it and view the results. Adjust and run again until you get it
> correct.
> >
> > It's a royal pain but it seems to work this way. It would sure be nice
> > to create a GRASS workspace file and just say "convert this workspace to
> > an image" with everything all laid out nicely - like Arc does exporting
> > their mxd map files...
> >
> > I hope this helps someone !
> > :slight_smile:
> > Chris
> >
> > On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
> > <kratochanna@gmail.com <mailto:kratochanna@gmail.com> <mailto:kratochanna@gmail.com>> wrote:
> >
> > On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>
> <mailto:surfcjb@yahoo.com>
> > <mailto:surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>>> wrote:
> >
> > Hi Anna - thank you for the suggestion - I tried it but alas, still
> > it only outputs a single vector map (layer). I can get either the
> > Country vector or the admin_areas vector, but not both overlaid.
> > :frowning:
> > Chris
> >
> > I realized you are using both environmental variables and d.mon, that
> > might cause some issues, you use one or the other. So try to remove the
> > lines starting with d.mon.
> >
> > Hope that helps,
> > Anna
> >
> > On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
> > <kratochanna@gmail.com <mailto:kratochanna@gmail.com> <mailto:kratochanna@gmail.com>
> <mailto:kratochanna@gmail.com <mailto:kratochanna@gmail.com>>> wrote:
> >
> > Hi,
> >
> > On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
> > <grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> <mailto:grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>>>
> wrote:
> >
> > Good morning :slight_smile:
> > I'm using GRASS 7.4.1 on a Linux cluster so I only have
> > command-line capability. I have two vector layers (a country
> > boundary polygon and part of an administrative area map - also
> > polygons). I am trying to automate creating a PNG file of the
> > admin areas overlaying the country boundary therefore all work
> > has to be command-line (in a bash script). I've tried this two
> > ways - using the d.mon start=png method and also the ps.map
> > method as described below. The d.mon method appears to generate
> > the image with only one vector map (not both) and only colors
> > the borders - it won't use the fill_color setting. The ps.map
> > method seems to work but assumes the image is on a sheet of
> > paper so there's a ton of extra white-space. I'd like to use
> > d.mon but I can use ps.map if someone could please let me know
> > how to export only the computational region without all the
> > extra 'paper' in the image. Here's my code:
> >
> > g.region vector='Country'
> > export GRASS_RENDER_IMMEDIATE=png
> > export GRASS_RENDER_WIDTH=640
> > export GRASS_RENDER_HEIGHT=480
> > export GRASS_RENDER_TRANSPARENT=true
> > export GRASS_RENDER_TRUECOLOR=true
> > export GRASS_RENDER_FILE=$HOME/country_admin.png
> > export GRASS_RENDER_FILE_COMPRESSION=0
> > export GRASS_MESSAGE_FORMAT=plain
> > d.mon start=png
> > d.vect map=Country color=210:210:210 fill_color=153:153:153
> > display=shape type=area
> > d.vect map=admin_area color=153:153:153 rgb_column=area_color
> > display=shape type=area
> > d.mon stop=png
> >
> > This only produces a png with the last vector listed and only
> > the borders are colored with the rgb_column values.
> >
> > I think you are missing GRASS_RENDER_FILE_READ=TRUE:
> > https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;
> > <https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;&gt;
> >
> > Regarding rgb_column, I am not sure, didn't have time to test.
> >
> > Anna
> >
> > If I do this without the d.mon start/stop lines ... i.e. relying
> > on the GRASS_RENDER_IMMEDIATE=png only, then only one vector map
> > is converted to png however it DOES do the color fill properly.
> > With either above method the png is the correct size.
> >
> > Now using ps.map (same env variable set as above):
> >
> > g.region vector='Country'
> > ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
> > --overwrite
> > where ps_rules.txt is:
> > border y
> > color 81:81:81
> > end
> > vareas admin_area
> > layer 1
> > rgbcolumn area_color
> > color 153:153:153
> > end
> > vareas Country
> > color 210:210:210
> > fcolor 153:153:153
> > end
> >
> > We don't have pstopng but we do have ghostscript:
> >
> > gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
> > -dGraphicsAlphaBits=4 -r300 -sOutputFile=$HOME/country_admin.png
> > $HOME/country_admin.ps
> >
> > This creates the correct image (color fills, etc) but has white
> > margins and a lot of white space below the image likeit is
> > printed at the top of a piece of paper.
> >
> > does anyone have any idea how to create a png with multiple
> > vector maps overlaying each other (and not have the extra
> > whitespace too)?
> >
> > v/r
> > Chris
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> <mailto:grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>>
> > https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;
> > <https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;&gt;

>
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> > https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;
> >
>

Good afternoon Moritz - thank you for the feedback :slight_smile:
I’ve been able to get GRASS 7.8 running with msys on my pc so I can send images etc. now… I tried repeating what I had done at work and I have the same results … I also downloaded the Spearfish dataset as you suggested and brought in the boundary_county vector. I can go into Properties and fill color orange and outline gray, but I go to the console and do the d.vect map=boundary_county color=red fill_color=orange and all I get is the red boundaries.I attached an image of everything … the Layer Manager, the Display window, the msys console window with my commands run and all my exported GRASS variables, and the resultant png image.
I’ve tried this with several other polygon vector files and I get the same darn thing. Can you see anything wrong with my variable settings ?

GRASS 7.8.4> v.info -t boundary_county@WarningPoints #from the Spearfish dataset
nodes=1114
points=0
lines=0
boundaries=1910
centroids=926
areas=926
islands=130
primitives=2836

map3d=0

GRASS 7.8.4> env | grep GRASS
MANPATH=C:\OSGEO4~1\apps\grass\grass78\docs\man;C:\Users\Chris\AppData\Roaming\GRASS7\addons\docs\man
GRASS_PYTHON=C:\OSGEO4~1\bin\python3.exe
GRASS_RENDER_TRANSPARENCY=true
GRASS_PAGER=more
GRASS_GNUPLOT=gnuplot -persist
GRASS_RENDER_PNG_COMPRESSION=0
GRASS_RENDER_FILE_COMPRESSION=0
GRASSBIN=C:\OSGEO4~1\apps\grass\grass78\bin
GRASS_RENDER_FILE=test.png
GRASS_SH=C:\OSGEO4~1\apps\msys\bin\sh.exe
GRASS_RENDER_HEIGHT=480
PATH=/c/OSGEO4~1/apps/grass/grass78/lib:/c/OSGEO4~1/apps/grass/grass78/bin:/c/Users/Chris/AppData/Roaming/GRASS7/addons/bin:/c/OSGEO4~1/apps/Python37:/c/OSGEO4~1/apps/Python37/Scripts:/c/OSGEO4~1/apps/Python27/Scripts:/c/OSGEO4~1/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/system32/WBem:/usr/bin:/c/Program Files/RStudio/bin:/c/OSGEO4~1/apps/grass/grass78/bin:/c/OSGEO4~1/apps/grass/grass78/scripts:/c/OSGEO4~1/apps/grass/grass78/lib:.:/c/OSGEO4~1/apps/Python37/lib/site-packages/pywin32_system32
GRASS_MESSAGE_FORMAT=plain
GRASS_PROJSHARE=C:\OSGEO4~1\share\proj
PS1=GRASS 7.8.4>
GRASS_VERSION=7.8.4
GRASS_HTML_BROWSER=start
GRASS_RENDER_WIDTH=640
GRASS_RENDER_TRUECOLOR=true
GRASS_RENDER_IMMEDIATE=png

GRASS_ADDON_BASE=C:\Users\Chris\AppData\Roaming\GRASS7\addons
GRASS_RENDER_FILE_READ=true

GRASS 7.8.4> d.vect map=boundary_county@WarningPoints color=red fill_color=orange
d.vect complete.

GRASS 7.8.4>

Thanks again … and sorry to bother you so much!
:slight_smile:

Chris

On Wednesday, February 17, 2021, 7:57:08 AM EST, Moritz Lennert mlennert@club.worldonline.be wrote:

Hi Chris,

On 17/02/21 02:30, Chris Bartolomei wrote:

Ohhhhh !! Sooooooo close ! I can get the two vector maps to overlay and

display but no matter what I do I cannot get them to do a color fill …

ugh … fill_color does nothing. I can use "d.vect map=admin_area

color=red" and the boundaries change to red, but "d.vect map=admin_area

color=black fill_color=red" and i do not get any filled color. So

frustrating. I thought maybe my shapefile imported as just a boundary

but when I do a “v.category input=admin_area option=report” I get:

Layer/table 1/admin_area

type count min max

point 0 0 0

line 0 0 0

boundary 0 0 0

centroid 59 1 25

area 0 0 0

face 0 0 0

kernel 0 0 0

all 59 1 25

Should I have areas in there too ??

I’m not really sure what ‘area’ in the output of v.category actually

refers to, as areas cannot have categories in GRASS GIS.

In order to see if you have areas in your file, check with v.info:

I wonder if the import went wonky… what is strange is that the ps.map

tool fills the polygons just fine.

Moritz - could please I ask you to do a v.category on one of your vector

maps (v.category input=censuslbk_wwake@PERMANENT option=report) and see

if it has areas in it or just centroids like I have?

GRASS 7.8.5 (nc_spm_08_grass7):~ > v.info -t boundary_county

nodes=1114

points=0

lines=0

boundaries=1910

centroids=926

areas=926

islands=130

primitives=2836

map3d=0

but

v.category boundary_county op=report

Layer/table: 1/boundary_county

type count min max

point 0 0 0

line 0 0 0

boundary 0 0 0

centroid 926 1 926

area 0 0 0

face 0 0 0

kernel 0 0 0

all 926 1 926

In order to find out if the issue comes from your data or from your

installation of GRASS GIS, you can also download the NC demo data set

from https://grass.osgeo.org/download/data/#NorthCarolinaDataset and try

to reproduce what I did in order to see if it works.

Moritz

On Tuesday, February 16, 2021, 11:20:31 AM EST, Chris Bartolomei

<surfcjb@yahoo.com> wrote:

Well - that does indeed work for you. I’ll try your settings when I get

into the office - we’re running GRASS on a RHEL 7 cluster - and see what

I can come up with.

It would be sooo much better if it worked like yours did!

Thank you so much for taking the time and testing this out

:slight_smile:

v/r

Chris

On Tuesday, February 16, 2021, 11:07:10 AM EST, Moritz Lennert

<mlennert@club.worldonline.be> wrote:

On 16/02/21 15:54, Chris Bartolomei wrote:

Mortiz - are those vector layers areas ? I’m guessing the census is an

area, the roads are lines and the schools are points, yes? I’m having

an issue overlaying two area maps (polygons). i can only get one to show

… I have tried your method with all the export GRASS_RENDER* variables

but I have a country polygon map as the bottom later and a selection of

a few administrative areas (provinces/states) as the top map and I can

only get one or the other to show up. It almost seems as if the

transparency doesn’t work and what should be transparent in the admin

map is actually the background color and blocks the country from

being seen.

Could you please try your method with a couple area (polygon) vector

maps overlaying each other?

export GRASS_RENDER_IMMEDIATE=png

export GRASS_RENDER_WIDTH=640

export GRASS_RENDER_HEIGHT=480

export GRASS_RENDER_TRUECOLOR=true

export GRASS_RENDER_FILE_COMPRESSION=0

export GRASS_MESSAGE_FORMAT=plain

export GRASS_RENDER_FILE_READ=TRUE

export GRASS_RENDER_FILE=$HOME/test.png

g.region vect=census_wake2000

d.vect map=census_wake2000@PERMANENT mailto:[census_wake2000@PERMANENT](mailto:census_wake2000@PERMANENT)

fill_color=grey

d.vect map=censusblk_swwake@PERMANENT

mailto:[censusblk_swwake@PERMANENT](mailto:censusblk_swwake@PERMANENT) fill_color=red

I’ve tried with

export GRASS_RENDER_TRANSPARENT=TRUE

and

export GRASS_RENDER_TRANSPARENT=FALSE

As you can see in the attached images, the overlay seems to work without

any issues (or I don’t understand what you are looking for exactly) and

setting GRASS_RENDER_TRANSPARENT decides on whether the background

should be transparent or not.

A second test in the same data set, but with different layers:

export GRASS_RENDER_TRANSPARENT=TRUE

export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png

g.region vect=boundary_county

d.vect map=boundary_county@PERMANENT mailto:[boundary_county@PERMANENT](mailto:boundary_county@PERMANENT)

d.vect map=boundary_municp@PERMANENT mailto:[boundary_municp@PERMANENT](mailto:boundary_municp@PERMANENT)

fill_color=255:255:0:255

export GRASS_RENDER_TRANSPARENT=FALSE

export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png

g.region vect=boundary_county

d.vect map=boundary_county@PERMANENT mailto:[boundary_county@PERMANENT](mailto:boundary_county@PERMANENT)

d.vect map=boundary_municp@PERMANENT mailto:[boundary_municp@PERMANENT](mailto:boundary_municp@PERMANENT)

fill_color=255:255:0:255

Again, the overlay works, at least as I would have expected.

Moritz

On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert

<mlennert@club.worldonline.be mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)>

wrote:

Hi Chris,

For me, the following works with the current stable GRASS GIS (7.8.5)

and using maps from the NC demo data set:

export GRASS_RENDER_IMMEDIATE=png

export GRASS_RENDER_WIDTH=640

export GRASS_RENDER_HEIGHT=480

export GRASS_RENDER_TRANSPARENT=true

export GRASS_RENDER_TRUECOLOR=true

export GRASS_RENDER_FILE_COMPRESSION=0

export GRASS_MESSAGE_FORMAT=plain

export GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000

d.vect map=census_wake2000@PERMANENT

mailto:[census_wake2000@PERMANENT](mailto:census_wake2000@PERMANENT) <mailto:census_wake2000@PERMANENT

mailto:[census_wake2000@PERMANENT](mailto:census_wake2000@PERMANENT)>

fill_color=none

d.vect map=roadsmajor@PERMANENT mailto:[roadsmajor@PERMANENT](mailto:roadsmajor@PERMANENT)

<mailto:roadsmajor@PERMANENT mailto:[roadsmajor@PERMANENT](mailto:roadsmajor@PERMANENT)>

color=255:0:0:255

d.vect map=schools_wake@PERMANENT mailto:[schools_wake@PERMANENT](mailto:schools_wake@PERMANENT)

<mailto:schools_wake@PERMANENT mailto:[schools_wake@PERMANENT](mailto:schools_wake@PERMANENT)>

fill_color=0:128:0:255

icon=basic/circle size=10

I attach a small thumbnail of the resulting PNG file.

Moritz

On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:

Good morning Anna,

It took quite a while of trial and error but I worked out a method

that

kindof works:

First off - unless someone says otherwise, you can’t use the PNG

driver

(d.mon) method to overlay more than one polygon vector. Sorry - it

just

doesn’t work. You CAN use the ps.map method - that works really well

generating the image however it by default assumes you are printing on

an A4 piece of paper so there’s all sorts of white space. The

image is

centered at the top of this fictional piece of paper. In your

postscript

rules file you can use the “maploc” command to position the image

elsewhere on the page. This is necessary because the next trick

changes

the paper dimensions but it assumes the origin is the lower left

corner

and therefore clips anything that is above the new dimensions. Back to

postscript commands in the rules file first though … the ps.map

maploc

command uses inches (why?? it should be points) so an A4 page is

8.27" x

11.69" points are 1/72 of an inch thus 595p x 842p - it also has a

default 36p margin (0.5 inch). You’ll need those numbers later. maploc

also lets you set the size of your image box: maploc {x offset from

left edge} {y offset from top} {width of box} {height of box}

Note: this

is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not

python. This is my postscript rules file:

maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the

bottom of the page

note that if you push it too far down to where the box would run off

the bottom, the image is

resized to fit on the page so do some testing to come up with the

correct values

also I found the computational region controls the aspect ratio so

although I say

6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8

inch box.

border y # add a border to the map frame (box)

color 81:81:81 # shade of gray

end # end the border controls

vareas admin_area # top vector layer to display

layer 1 # attribute table to use

rgbcolumn area_color # name of column holding R:G:B values to fill

the polygons

color 153:153:153 #boundary color

end # end the admin_area controls

vareas Country # this is the bottom vectors to display

color 210:210:210 #boundary color

fcolor 153:153:153 #fill color for all polygons

end # end the Country controls

Here’s the command to run to generate the postscript file:

ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite

To convert the postscript to PNG I had to use ghostscript - there are

other tools you can use though.

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4

-dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276

-dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c

“<</PageOffset [-34 78]>> setpagedevice” -f $HOME/color_admin.ps

So the above line needs some explaining

(http://www.ghostscript.com/doc/9.27/Use.htm

<http://www.ghostscript.com/doc/9.27/Use.htm >

<http://www.ghostscript.com/doc/9.27/Use.htm

<http://www.ghostscript.com/doc/9.27/Use.htm>>) but in a nutshell, the

parameters to play with are first the Pageoffset [x y] values.

They are

in points not inches … 1/72 inch = 1 point … remember the 1/2"

margins? the -34 gives me 2 points of white space to the left edge of

the map frame, the 78 I had to play with to push the map frame down to

the right spot.

Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS … again in

points

… this “trims” the paper to height and width … set something then

run it and view the results. Adjust and run again until you get it

correct.

It’s a royal pain but it seems to work this way. It would sure be nice

to create a GRASS workspace file and just say "convert this

workspace to

an image" with everything all laid out nicely - like Arc does

exporting

their mxd map files…

I hope this helps someone !

:slight_smile:

Chris

On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová

<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)

<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)>> wrote:

On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com

mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)

<mailto:surfcjb@yahoo.com mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)>

<mailto:surfcjb@yahoo.com mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)

<mailto:surfcjb@yahoo.com mailto:[surfcjb@yahoo.com](mailto:surfcjb@yahoo.com)>>> wrote:

Hi Anna - thank you for the suggestion - I tried it but alas, still

it only outputs a single vector map (layer). I can get either the

Country vector or the admin_areas vector, but not both overlaid.

:frowning:

Chris

I realized you are using both environmental variables and d.mon, that

might cause some issues, you use one or the other. So try to

remove the

lines starting with d.mon.

Hope that helps,

Anna

On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová

<kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)

<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)>

<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)

<mailto:kratochanna@gmail.com mailto:[kratochanna@gmail.com](mailto:kratochanna@gmail.com)>>> wrote:

Hi,

On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user

<grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)

<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>

<mailto:grass-user@lists.osgeo.org

mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org) <mailto:grass-user@lists.osgeo.org

mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>>>

wrote:

Good morning :slight_smile:

I’m using GRASS 7.4.1 on a Linux cluster so I only have

command-line capability. I have two vector layers (a country

boundary polygon and part of an administrative area map - also

polygons). I am trying to automate creating a PNG file of the

admin areas overlaying the country boundary therefore all work

has to be command-line (in a bash script). I’ve tried this two

ways - using the d.mon start=png method and also the ps.map

method as described below. The d.mon method appears to generate

the image with only one vector map (not both) and only colors

the borders - it won’t use the fill_color setting. The ps.map

method seems to work but assumes the image is on a sheet of

paper so there’s a ton of extra white-space. I’d like to use

d.mon but I can use ps.map if someone could please let me know

how to export only the computational region without all the

extra ‘paper’ in the image. Here’s my code:

g.region vector=‘Country’

export GRASS_RENDER_IMMEDIATE=png

export GRASS_RENDER_WIDTH=640

export GRASS_RENDER_HEIGHT=480

export GRASS_RENDER_TRANSPARENT=true

export GRASS_RENDER_TRUECOLOR=true

export GRASS_RENDER_FILE=$HOME/country_admin.png

export GRASS_RENDER_FILE_COMPRESSION=0

export GRASS_MESSAGE_FORMAT=plain

d.mon start=png

d.vect map=Country color=210:210:210 fill_color=153:153:153

display=shape type=area

d.vect map=admin_area color=153:153:153 rgb_column=area_color

display=shape type=area

d.mon stop=png

This only produces a png with the last vector listed and only

the borders are colored with the rgb_column values.

I think you are missing GRASS_RENDER_FILE_READ=TRUE:

https://grass.osgeo.org/grass78/manuals/pngdriver.html

<https://grass.osgeo.org/grass78/manuals/pngdriver.html >

<https://grass.osgeo.org/grass78/manuals/pngdriver.html

<https://grass.osgeo.org/grass78/manuals/pngdriver.html>>

<https://grass.osgeo.org/grass78/manuals/pngdriver.html

<https://grass.osgeo.org/grass78/manuals/pngdriver.html >

<https://grass.osgeo.org/grass78/manuals/pngdriver.html

<https://grass.osgeo.org/grass78/manuals/pngdriver.html>>>

Regarding rgb_column, I am not sure, didn’t have time to test.

Anna

If I do this without the d.mon start/stop lines … i.e.

relying

on the GRASS_RENDER_IMMEDIATE=png only, then only one

vector map

is converted to png however it DOES do the color fill properly.

With either above method the png is the correct size.

Now using ps.map (same env variable set as above):

g.region vector=‘Country’

ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps

–overwrite

where ps_rules.txt is:

border y

color 81:81:81

end

vareas admin_area

layer 1

rgbcolumn area_color

color 153:153:153

end

vareas Country

color 210:210:210

fcolor 153:153:153

end

We don’t have pstopng but we do have ghostscript:

gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4

-dGraphicsAlphaBits=4 -r300

-sOutputFile=$HOME/country_admin.png

$HOME/country_admin.ps

This creates the correct image (color fills, etc) but has white

margins and a lot of white space below the image likeit is

printed at the top of a piece of paper.

does anyone have any idea how to create a png with multiple

vector maps overlaying each other (and not have the extra

whitespace too)?

v/r

Chris


grass-user mailing list

grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)

<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>

<mailto:grass-user@lists.osgeo.org

mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org) <mailto:grass-user@lists.osgeo.org

mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>>

https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user >

<https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user>>

<https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user >

<https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user>>>


grass-user mailing list

grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)

<mailto:grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)>

https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user >

<https://lists.osgeo.org/mailman/listinfo/grass-user

<https://lists.osgeo.org/mailman/listinfo/grass-user>>

(attachments)

GRASS_render_png.PNG

Sorry, Chris, I lost this out of my sight.

I don't see anything immediately wrong. Maybe it is a specific MS Windows issue I cannot reproduce here in GNU/Linux.

@Helmut any ideas ?

Moritz

On 17/02/21 19:17, Chris Bartolomei wrote:

Good afternoon Moritz - thank you for the feedback :slight_smile:
I've been able to get GRASS 7.8 running with msys on my pc so I can send images etc. now... I tried repeating what I had done at work and I have the same results ... I also downloaded the Spearfish dataset as you suggested and brought in the boundary_county vector. I can go into Properties and fill color orange and outline gray, but I go to the console and do the d.vect map=boundary_county color=red fill_color=orange and all I get is the red boundaries.I attached an image of everything ... the Layer Manager, the Display window, the msys console window with my commands run and all my exported GRASS variables, and the resultant png image.
I've tried this with several other polygon vector files and I get the same darn thing. Can you see anything wrong with my variable settings ?

GRASS 7.8.4> v.info -t boundary_county@WarningPoints #from the Spearfish dataset
nodes=1114
points=0
lines=0
boundaries=1910
centroids=926
areas=926
islands=130
primitives=2836
map3d=0

GRASS 7.8.4> env | grep GRASS
MANPATH=C:\OSGEO4~1\apps\grass\grass78\docs\man;C:\Users\Chris\AppData\Roaming\GRASS7\addons\docs\man
GRASS_PYTHON=C:\OSGEO4~1\bin\python3.exe
GRASS_RENDER_TRANSPARENCY=true
GRASS_PAGER=more
GRASS_GNUPLOT=gnuplot -persist
GRASS_RENDER_PNG_COMPRESSION=0
GRASS_RENDER_FILE_COMPRESSION=0
GRASSBIN=C:\OSGEO4~1\apps\grass\grass78\bin
GRASS_RENDER_FILE=test.png
GRASS_SH=C:\OSGEO4~1\apps\msys\bin\sh.exe
GRASS_RENDER_HEIGHT=480
PATH=/c/OSGEO4~1/apps/grass/grass78/lib:/c/OSGEO4~1/apps/grass/grass78/bin:/c/Users/Chris/AppData/Roaming/GRASS7/addons/bin:/c/OSGEO4~1/apps/Python37:/c/OSGEO4~1/apps/Python37/Scripts:/c/OSGEO4~1/apps/Python27/Scripts:/c/OSGEO4~1/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/system32/WBem:/usr/bin:/c/Program Files/RStudio/bin:/c/OSGEO4~1/apps/grass/grass78/bin:/c/OSGEO4~1/apps/grass/grass78/scripts:/c/OSGEO4~1/apps/grass/grass78/lib:.:/c/OSGEO4~1/apps/Python37/lib/site-packages/pywin32_system32
GRASS_MESSAGE_FORMAT=plain
GRASS_PROJSHARE=C:\OSGEO4~1\share\proj
PS1=GRASS 7.8.4>
GRASS_VERSION=7.8.4
GRASS_HTML_BROWSER=start
GRASS_RENDER_WIDTH=640
GRASS_RENDER_TRUECOLOR=true
GRASS_RENDER_IMMEDIATE=png
GRASS_ADDON_BASE=C:\Users\Chris\AppData\Roaming\GRASS7\addons
GRASS_RENDER_FILE_READ=true

GRASS 7.8.4> d.vect map=boundary_county@WarningPoints color=red fill_color=orange
d.vect complete.
GRASS 7.8.4>

Thanks again ... and sorry to bother you so much!
:slight_smile:
Chris

On Wednesday, February 17, 2021, 7:57:08 AM EST, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Hi Chris,

On 17/02/21 02:30, Chris Bartolomei wrote:
> Ohhhhh !! Sooooooo close ! I can get the two vector maps to overlay and
> display but no matter what I do I cannot get them to do a color fill ...
> ugh ... fill_color does nothing. I can use "d.vect map=admin_area
> color=red" and the boundaries change to red, but "d.vect map=admin_area
> color=black fill_color=red" and i do not get any filled color. So
> frustrating. I thought maybe my shapefile imported as just a boundary
> but when I do a "v.category input=admin_area option=report" I get:
> Layer/table 1/admin_area
> type count min max
> point 0 0 0
> line 0 0 0
> boundary 0 0 0
> centroid 59 1 25
> area 0 0 0
> face 0 0 0
> kernel 0 0 0
> all 59 1 25
>
> Should I have areas in there too ??

I'm not really sure what 'area' in the output of v.category actually
refers to, as areas cannot have categories in GRASS GIS.

In order to see if you have areas in your file, check with v.info:

> I wonder if the import went wonky.... what is strange is that the ps.map
> tool fills the polygons just fine.
> Moritz - could please I ask you to do a v.category on one of your vector
> maps (v.category input=censuslbk_wwake@PERMANENT <mailto:censuslbk_wwake@PERMANENT> option=report) and see
> if it has areas in it or just centroids like I have?

GRASS 7.8.5 (nc_spm_08_grass7):~ > v.info -t boundary_county
nodes=1114
points=0
lines=0
boundaries=1910
centroids=926
areas=926
islands=130
primitives=2836
map3d=0

but

>v.category boundary_county op=report
Layer/table: 1/boundary_county
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 926 1 926
area 0 0 0
face 0 0 0
kernel 0 0 0
all 926 1 926

In order to find out if the issue comes from your data or from your
installation of GRASS GIS, you can also download the NC demo data set
from https://grass.osgeo.org/download/data/#NorthCarolinaDataset >and try
to reproduce what I did in order to see if it works.

Moritz

> On Tuesday, February 16, 2021, 11:20:31 AM EST, Chris Bartolomei
> <surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>> wrote:
>
> Well - that does indeed work for you. I'll try your settings when I get
> into the office - we're running GRASS on a RHEL 7 cluster - and see what
> I can come up with.
> It would be sooo much better if it worked like yours did!
> Thank you so much for taking the time and testing this out
> :slight_smile:
> v/r
> Chris
>
> On Tuesday, February 16, 2021, 11:07:10 AM EST, Moritz Lennert
> <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:
>
> On 16/02/21 15:54, Chris Bartolomei wrote:
> > Mortiz - are those vector layers areas ? I'm guessing the census is an
> > area, the roads are lines and the schools are points, yes? I'm having
> > an issue overlaying two area maps (polygons). i can only get one to show
> > ... I have tried your method with all the export GRASS_RENDER* variables
> > but I have a country polygon map as the bottom later and a selection of
> > a few administrative areas (provinces/states) as the top map and I can
> > only get one or the other to show up. It almost seems as if the
> > transparency doesn't work and what should be transparent in the admin
> > map is actually the background color and blocks the country from
> being seen.
> > Could you please try your method with a couple area (polygon) vector
> > maps overlaying each other?
>
> export GRASS_RENDER_IMMEDIATE=png
> export GRASS_RENDER_WIDTH=640
> export GRASS_RENDER_HEIGHT=480
> export GRASS_RENDER_TRUECOLOR=true
> export GRASS_RENDER_FILE_COMPRESSION=0
> export GRASS_MESSAGE_FORMAT=plain
> export GRASS_RENDER_FILE_READ=TRUE
> export GRASS_RENDER_FILE=$HOME/test.png
>
> g.region vect=census_wake2000
> d.vect map=census_wake2000@PERMANENT <mailto:census_wake2000@PERMANENT> <mailto:census_wake2000@PERMANENT>
> fill_color=grey
> d.vect map=censusblk_swwake@PERMANENT <mailto:censusblk_swwake@PERMANENT>
> <mailto:censusblk_swwake@PERMANENT> fill_color=red
>
> I've tried with
>
> export GRASS_RENDER_TRANSPARENT=TRUE
> and
> export GRASS_RENDER_TRANSPARENT=FALSE
>
> As you can see in the attached images, the overlay seems to work without
> any issues (or I don't understand what you are looking for exactly) and
> setting GRASS_RENDER_TRANSPARENT decides on whether the background
> should be transparent or not.
>
> A second test in the same data set, but with different layers:
>
> export GRASS_RENDER_TRANSPARENT=TRUE
> export GRASS_RENDER_FILE=$HOME/test_NC_TRUE.png
> g.region vect=boundary_county
> d.vect map=boundary_county@PERMANENT <mailto:boundary_county@PERMANENT> <mailto:boundary_county@PERMANENT>
> d.vect map=boundary_municp@PERMANENT <mailto:boundary_municp@PERMANENT> <mailto:boundary_municp@PERMANENT>
> fill_color=255:255:0:255
>
> export GRASS_RENDER_TRANSPARENT=FALSE
> export GRASS_RENDER_FILE=$HOME/test_NC_FALSE.png
> g.region vect=boundary_county
> d.vect map=boundary_county@PERMANENT <mailto:boundary_county@PERMANENT> <mailto:boundary_county@PERMANENT>
> d.vect map=boundary_municp@PERMANENT <mailto:boundary_municp@PERMANENT> <mailto:boundary_municp@PERMANENT>
> fill_color=255:255:0:255
>
> Again, the overlay works, at least as I would have expected.
>
> Moritz
>
> > On Tuesday, February 16, 2021, 4:19:16 AM EST, Moritz Lennert
> > <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be> <mailto:mlennert@club.worldonline.be>>
> wrote:
> >
> > Hi Chris,
> >
> > For me, the following works with the current stable GRASS GIS (7.8.5)
> > and using maps from the NC demo data set:
> >
> > export GRASS_RENDER_IMMEDIATE=png
> > export GRASS_RENDER_WIDTH=640
> > export GRASS_RENDER_HEIGHT=480
> > export GRASS_RENDER_TRANSPARENT=true
> > export GRASS_RENDER_TRUECOLOR=true
> > export GRASS_RENDER_FILE_COMPRESSION=0
> > export GRASS_MESSAGE_FORMAT=plain
> > export GRASS_RENDER_FILE_READ=TRUE
> >
> > g.region vect=census_wake2000
> > d.vect map=census_wake2000@PERMANENT <mailto:census_wake2000@PERMANENT>
> <mailto:census_wake2000@PERMANENT> <mailto:census_wake2000@PERMANENT
> <mailto:census_wake2000@PERMANENT>>
> > fill_color=none
> > d.vect map=roadsmajor@PERMANENT <mailto:roadsmajor@PERMANENT> <mailto:roadsmajor@PERMANENT>
> <mailto:roadsmajor@PERMANENT <mailto:roadsmajor@PERMANENT>>
> > color=255:0:0:255
> > d.vect map=schools_wake@PERMANENT <mailto:schools_wake@PERMANENT> <mailto:schools_wake@PERMANENT>
> <mailto:schools_wake@PERMANENT <mailto:schools_wake@PERMANENT>>
> > fill_color=0:128:0:255
> > icon=basic/circle size=10
> >
> > I attach a small thumbnail of the resulting PNG file.
> >
> > Moritz
> >
> > On 11/02/21 18:54, Chris Bartolomei via grass-user wrote:
> > > Good morning Anna,
> > > It took quite a while of trial and error but I worked out a method
> that
> > > kindof works:
> > > First off - unless someone says otherwise, you can't use the PNG
> driver
> > > (d.mon) method to overlay more than one polygon vector. Sorry - it
> just
> > > doesn't work. You CAN use the ps.map method - that works really well
> > > generating the image however it by default assumes you are printing on
> > > an A4 piece of paper so there's all sorts of white space. The
> image is
> > > centered at the top of this fictional piece of paper. In your
> postscript
> > > rules file you can use the "maploc" command to position the image
> > > elsewhere on the page. This is necessary because the next trick
> changes
> > > the paper dimensions but it assumes the origin is the lower left
> corner
> > > and therefore clips anything that is above the new dimensions. Back to
> > > postscript commands in the rules file first though ... the ps.map
> maploc
> > > command uses inches (why?? it should be points) so an A4 page is
> 8.27" x
> > > 11.69" points are 1/72 of an inch thus 595p x 842p - it also has a
> > > default 36p margin (0.5 inch). You'll need those numbers later. maploc
> > > also lets you set the size of your image box: maploc {x offset from
> > > left edge} {y offset from top} {width of box} {height of box}
> Note: this
> > > is all done via a BASH script with GRASS 7.4 on Linux (RHEL 7), not
> > > python. This is my postscript rules file:
> > >
> > > maploc 0.1 6.815 6.5 4.875 #468p x 351p map box moved down towards the
> > > bottom of the page
> > > # note that if you push it too far down to where the box would run off
> > > the bottom, the image is
> > > # resized to fit on the page so do some testing to come up with the
> > > correct values
> > > # also I found the computational region controls the aspect ratio so
> > > although I say
> > > # 6.5 x 4.875 with the above maploc command, I got a 6.5 x 3.8
> inch box.
> > > border y # add a border to the map frame (box)
> > > color 81:81:81 # shade of gray
> > > end # end the border controls
> > > vareas admin_area # top vector layer to display
> > > layer 1 # attribute table to use
> > > rgbcolumn area_color # name of column holding R:G:B values to fill
> > > the polygons
> > > color 153:153:153 #boundary color
> > > end # end the admin_area controls
> > > vareas Country # this is the bottom vectors to display
> > > color 210:210:210 #boundary color
> > > fcolor 153:153:153 #fill color for all polygons
> > > end # end the Country controls
> > >
> > > Here's the command to run to generate the postscript file:
> > >
> > > ps.map input=$HOME/ps_rules.txt out=$HOME/color_admin.ps --overwrite
> > >
> > > To convert the postscript to PNG I had to use ghostscript - there are
> > > other tools you can use though.
> > >
> > > gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -dTextAlphaBits=4
> > > -dGraphicsAlphaBits=4 -dDEVICEWIDTHPOINTS=473 -dDEVICEHEIGHTPOINTS=276
> > > -dFIXEDMEDIA -dPSFitPage -sOutputFile=$HOME/color_admin.png -c
> > > "<</PageOffset [-34 78]>> setpagedevice" -f $HOME/color_admin.ps
> > >
> > > So the above line needs some explaining
> > > (http://www.ghostscript.com/doc/9.27/Use.htm >
> <http://www.ghostscript.com/doc/9.27/Use.htm >>
> > <http://www.ghostscript.com/doc/9.27/Use.htm >
> <http://www.ghostscript.com/doc/9.27/Use.htm&gt;&gt;\) but in a nutshell, the
> > > parameters to play with are first the Pageoffset [x y] values.
> They are
> > > in points not inches ... 1/72 inch = 1 point ... remember the 1/2"
> > > margins? the -34 gives me 2 points of white space to the left edge of
> > > the map frame, the 78 I had to play with to push the map frame down to
> > > the right spot.
> > > Next is the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS ... again in
> points
> > > ... this "trims" the paper to height and width ... set something then
> > > run it and view the results. Adjust and run again until you get it
> > correct.
> > >
> > > It's a royal pain but it seems to work this way. It would sure be nice
> > > to create a GRASS workspace file and just say "convert this
> workspace to
> > > an image" with everything all laid out nicely - like Arc does
> exporting
> > > their mxd map files...
> > >
> > > I hope this helps someone !
> > > :slight_smile:
> > > Chris
> > >
> > > On Wednesday, February 10, 2021, 11:08:00 PM EST, Anna Petrášová
> > > <kratochanna@gmail.com <mailto:kratochanna@gmail.com> <mailto:kratochanna@gmail.com>
> <mailto:kratochanna@gmail.com <mailto:kratochanna@gmail.com>>> wrote:
> > >
> > > On Tue, Feb 9, 2021 at 4:41 PM Chris Bartolomei <surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>
> <mailto:surfcjb@yahoo.com>
> > <mailto:surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>>
> > > <mailto:surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>
> <mailto:surfcjb@yahoo.com <mailto:surfcjb@yahoo.com>>>> wrote:
> > >
> > > Hi Anna - thank you for the suggestion - I tried it but alas, still
> > > it only outputs a single vector map (layer). I can get either the
> > > Country vector or the admin_areas vector, but not both overlaid.
> > > :frowning:
> > > Chris
> > >
> > > I realized you are using both environmental variables and d.mon, that
> > > might cause some issues, you use one or the other. So try to
> remove the
> > > lines starting with d.mon.
> > >
> > > Hope that helps,
> > > Anna
> > >
> > > On Tuesday, February 9, 2021, 1:20:52 PM EST, Anna Petrášová
> > > <kratochanna@gmail.com <mailto:kratochanna@gmail.com> <mailto:kratochanna@gmail.com>
> <mailto:kratochanna@gmail.com <mailto:kratochanna@gmail.com>>
> > <mailto:kratochanna@gmail.com <mailto:kratochanna@gmail.com>
> <mailto:kratochanna@gmail.com <mailto:kratochanna@gmail.com>>>> wrote:
> > >
> > > Hi,
> > >
> > > On Tue, Feb 9, 2021 at 10:25 AM Chris Bartolomei via grass-user
> > > <grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> <mailto:grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>>
> > <mailto:grass-user@lists.osgeo.org
> <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org
> <mailto:grass-user@lists.osgeo.org>>>>
> > wrote:
> > >
> > > Good morning :slight_smile:
> > > I'm using GRASS 7.4.1 on a Linux cluster so I only have
> > > command-line capability. I have two vector layers (a country
> > > boundary polygon and part of an administrative area map - also
> > > polygons). I am trying to automate creating a PNG file of the
> > > admin areas overlaying the country boundary therefore all work
> > > has to be command-line (in a bash script). I've tried this two
> > > ways - using the d.mon start=png method and also the ps.map
> > > method as described below. The d.mon method appears to generate
> > > the image with only one vector map (not both) and only colors
> > > the borders - it won't use the fill_color setting. The ps.map
> > > method seems to work but assumes the image is on a sheet of
> > > paper so there's a ton of extra white-space. I'd like to use
> > > d.mon but I can use ps.map if someone could please let me know
> > > how to export only the computational region without all the
> > > extra 'paper' in the image. Here's my code:
> > >
> > > g.region vector='Country'
> > > export GRASS_RENDER_IMMEDIATE=png
> > > export GRASS_RENDER_WIDTH=640
> > > export GRASS_RENDER_HEIGHT=480
> > > export GRASS_RENDER_TRANSPARENT=true
> > > export GRASS_RENDER_TRUECOLOR=true
> > > export GRASS_RENDER_FILE=$HOME/country_admin.png
> > > export GRASS_RENDER_FILE_COMPRESSION=0
> > > export GRASS_MESSAGE_FORMAT=plain
> > > d.mon start=png
> > > d.vect map=Country color=210:210:210 fill_color=153:153:153
> > > display=shape type=area
> > > d.vect map=admin_area color=153:153:153 rgb_column=area_color
> > > display=shape type=area
> > > d.mon stop=png
> > >
> > > This only produces a png with the last vector listed and only
> > > the borders are colored with the rgb_column values.
> > >
> > > I think you are missing GRASS_RENDER_FILE_READ=TRUE:
> > > https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html >>
> > <https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;&gt;
> > > <https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html >>
> > <https://grass.osgeo.org/grass78/manuals/pngdriver.html >
> <https://grass.osgeo.org/grass78/manuals/pngdriver.html&gt;&gt;&gt;
> > >
> > > Regarding rgb_column, I am not sure, didn't have time to test.
> > >
> > > Anna
> > >
> > > If I do this without the d.mon start/stop lines ... i.e.
> relying
> > > on the GRASS_RENDER_IMMEDIATE=png only, then only one
> vector map
> > > is converted to png however it DOES do the color fill properly.
> > > With either above method the png is the correct size.
> > >
> > > Now using ps.map (same env variable set as above):
> > >
> > > g.region vector='Country'
> > > ps.map input=$HOME/ps_rules.txt out=$HOME/country_admin.ps
> > > --overwrite
> > > where ps_rules.txt is:
> > > border y
> > > color 81:81:81
> > > end
> > > vareas admin_area
> > > layer 1
> > > rgbcolumn area_color
> > > color 153:153:153
> > > end
> > > vareas Country
> > > color 210:210:210
> > > fcolor 153:153:153
> > > end
> > >
> > > We don't have pstopng but we do have ghostscript:
> > >
> > > gs-dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4
> > > -dGraphicsAlphaBits=4 -r300
> -sOutputFile=$HOME/country_admin.png
> > > $HOME/country_admin.ps
> > >
> > > This creates the correct image (color fills, etc) but has white
> > > margins and a lot of white space below the image likeit is
> > > printed at the top of a piece of paper.
> > >
> > > does anyone have any idea how to create a png with multiple
> > > vector maps overlaying each other (and not have the extra
> > > whitespace too)?
> > >
> > > v/r
> > > Chris
> > >
> > > _______________________________________________
> > > grass-user mailing list
> > > grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> <mailto:grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>>
> > <mailto:grass-user@lists.osgeo.org
> <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org
> <mailto:grass-user@lists.osgeo.org>>>
> > > https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user >>
> > <https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;&gt;
> > > <https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user >>
> > <https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;&gt;&gt;
>
> >
> > >
> > > _______________________________________________
> > > grass-user mailing list
> > > grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org> <mailto:grass-user@lists.osgeo.org>
> <mailto:grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>>
> > > https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user >>
> > <https://lists.osgeo.org/mailman/listinfo/grass-user >
> <https://lists.osgeo.org/mailman/listinfo/grass-user&gt;&gt;
> > >
> >
>

I don't see anything immediately wrong. Maybe it is a specific MS
Windows issue I cannot reproduce here in GNU/Linux.

@Helmut any ideas ?

tested here in the following way in OSGeo4W-winGRASS 7.8.5

(1) changing the working directory via GUI > change working directory

cd "D:\temp\testgrassrender"
Working directory changed to:
"D:\temp\testgrassrender"

(2) in OSgeo4W-winGRASS-windows console (no msys needed!), also change here to the new wd:

C:\>cd D:\temp\testgrassrender
C:\>d:

(3) put the variables and d.-commands into a bat-file into the working directory (D:\temp\testgrassrender\mytest.bat):

REM start of the batch file

set GRASS_RENDER_IMMEDIATE=png
set GRASS_RENDER_WIDTH=640
set GRASS_RENDER_HEIGHT=480
set GRASS_RENDER_TRANSPARENT=true
set GRASS_RENDER_TRUECOLOR=true
set GRASS_RENDER_FILE_COMPRESSION=0
set GRASS_MESSAGE_FORMAT=plain
set GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000
d.vect map=census_wake2000 fill_color=none
d.vect map=roadsmajor color=255:0:0:255
d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10

REM end of the batch file

=> see here: in order to set a variable in the windows world, use e.g. set GRASS_RENDER_IMMEDIATE=png instead if export GRASS_RENDER_IMMEDIATE=png in the *nix world

(4) start your batch file in the windows command line:

D:\temp\testgrassrender>mytest.bat

D:\temp\testgrassrender>set GRASS_RENDER_IMMEDIATE=png
D:\temp\testgrassrender>set GRASS_RENDER_WIDTH=640
D:\temp\testgrassrender>set GRASS_RENDER_HEIGHT=480
D:\temp\testgrassrender>set GRASS_RENDER_TRANSPARENT=true
D:\temp\testgrassrender>set GRASS_RENDER_TRUECOLOR=true
D:\temp\testgrassrender>set GRASS_RENDER_FILE_COMPRESSION=0
D:\temp\testgrassrender>set GRASS_MESSAGE_FORMAT=plain
D:\temp\testgrassrender>set GRASS_RENDER_FILE_READ=TRUE
D:\temp\testgrassrender>g.region vect=census_wake2000
D:\temp\testgrassrender>d.vect map=census_wake2000 fill_color=none
d.vect komplett.

D:\temp\testgrassrender>d.vect map=roadsmajor color=255:0:0:255
d.vect komplett.

D:\temp\testgrassrender>d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10
d.vect komplett.

(5) see attached the result png - it looks like the same as Moritz's example

kind regards
Helmut

(attachments)

map_size_reduced.png

Helmut … thank you for your example however I think there is a misunderstanding of what I am trying to do. I am using GRASS on Linux (on a cluster) and the issue I am experiencing is overlaying two polygon maps (layers in Arc-speak). Points and lines on top of ONE set of polygons works fine as you have shown, however using two or more polygon maps (layers) does not seem to work. I attached an example of what i am trying to achieve: Take for instance a polygon representing Italy and you wanted it colored dark gray, then you want to overlay on top of that an administrative map showing only the areas of Lazio and Liguria colored in blue but no other administrative areas. The result would look like the Italy_sample.png file i attached (I made is using ArcPro as i am not in the office with access to our cluster). This is what is not working using the d.mon=png, d.vect tools. Could you please try something similar and see if it works for you (on linux)?
v/r
Chris

On Tuesday, March 2, 2021, 2:38:45 PM EST, Helmut Kudrnovsky hellik@web.de wrote:

I don’t see anything immediately wrong. Maybe it is a specific MS

Windows issue I cannot reproduce here in GNU/Linux.

@Helmut any ideas ?

tested here in the following way in OSGeo4W-winGRASS 7.8.5

(1) changing the working directory via GUI > change working directory

cd “D:\temp\testgrassrender”

Working directory changed to:

“D:\temp\testgrassrender”

(2) in OSgeo4W-winGRASS-windows console (no msys needed!), also change here to the new wd:

C:>cd D:\temp\testgrassrender

C:>d:

(3) put the variables and d.-commands into a bat-file into the working directory (D:\temp\testgrassrender\mytest.bat):

REM start of the batch file

set GRASS_RENDER_IMMEDIATE=png

set GRASS_RENDER_WIDTH=640

set GRASS_RENDER_HEIGHT=480

set GRASS_RENDER_TRANSPARENT=true

set GRASS_RENDER_TRUECOLOR=true

set GRASS_RENDER_FILE_COMPRESSION=0

set GRASS_MESSAGE_FORMAT=plain

set GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000

d.vect map=census_wake2000 fill_color=none

d.vect map=roadsmajor color=255:0:0:255

d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10

REM end of the batch file

=> see here: in order to set a variable in the windows world, use e.g. set GRASS_RENDER_IMMEDIATE=png instead if export GRASS_RENDER_IMMEDIATE=png in the *nix world

(4) start your batch file in the windows command line:

D:\temp\testgrassrender>mytest.bat

D:\temp\testgrassrender>set GRASS_RENDER_IMMEDIATE=png

D:\temp\testgrassrender>set GRASS_RENDER_WIDTH=640

D:\temp\testgrassrender>set GRASS_RENDER_HEIGHT=480

D:\temp\testgrassrender>set GRASS_RENDER_TRANSPARENT=true

D:\temp\testgrassrender>set GRASS_RENDER_TRUECOLOR=true

D:\temp\testgrassrender>set GRASS_RENDER_FILE_COMPRESSION=0

D:\temp\testgrassrender>set GRASS_MESSAGE_FORMAT=plain

D:\temp\testgrassrender>set GRASS_RENDER_FILE_READ=TRUE

D:\temp\testgrassrender>g.region vect=census_wake2000

D:\temp\testgrassrender>d.vect map=census_wake2000 fill_color=none

d.vect komplett.

D:\temp\testgrassrender>d.vect map=roadsmajor color=255:0:0:255

d.vect komplett.

D:\temp\testgrassrender>d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10

d.vect komplett.

(5) see attached the result png - it looks like the same as Moritz’s example

kind regards

Helmut

(attachments)

Italy.PNG
Italy_Admin.PNG
Italy_sample.PNG

Hi Chris,

In your previous message the settings you used had a lot of MS Windows paths in them, that’s why I thought you used that. If you’re not on Windows then these settings are wrong and this might explain your problem. Here’s what you sent:

GRASS 7.8.4> env | grep GRASS
MANPATH=C:\OSGEO4~1\apps\grass\grass78\docs\man;C:\Users\Chris\AppData\Roaming\GRASS7\addons\docs\man
GRASS_PYTHON=C:\OSGEO4~1\bin\python3.exe
GRASS_RENDER_TRANSPARENCY=true
GRASS_PAGER=more
GRASS_GNUPLOT=gnuplot -persist
GRASS_RENDER_PNG_COMPRESSION=0
GRASS_RENDER_FILE_COMPRESSION=0
GRASSBIN=C:\OSGEO4~1\apps\grass\grass78\bin
GRASS_RENDER_FILE=test.png
GRASS_SH=C:\OSGEO4~1\apps\msys\bin\sh.exe
GRASS_RENDER_HEIGHT=480
PATH=/c/OSGEO4~1/apps/grass/grass78/lib:/c/OSGEO4~1/apps/grass/grass78/bin:/c/Users/Chris/AppData/Roaming/GRASS7/addons/bin:/c/OSGEO4~1/apps/Python37:/c/OSGEO4~1/apps/Python37/Scripts:/c/OSGEO4~1/apps/Python27/Scripts:/c/OSGEO4~1/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/system32/WBem:/usr/bin:/c/Program Files/RStudio/bin:/c/OSGEO4~1/apps/grass/grass78/bin:/c/OSGEO4~1/apps/grass/grass78/scripts:/c/OSGEO4~1/apps/grass/grass78/lib:.:/c/OSGEO4~1/apps/Python37/lib/site-packages/pywin32_system32
GRASS_MESSAGE_FORMAT=plain
GRASS_PROJSHARE=C:\OSGEO4~1\share\proj
PS1=GRASS 7.8.4>
GRASS_VERSION=7.8.4
GRASS_HTML_BROWSER=start
GRASS_RENDER_WIDTH=640
GRASS_RENDER_TRUECOLOR=true
GRASS_RENDER_IMMEDIATE=png
GRASS_ADDON_BASE=C:\Users\Chris\AppData\Roaming\GRASS7\addons
GRASS_RENDER_FILE_READ=true

All the C:\ paths indicate Windows.

Moritz

Am 11. März 2021 21:37:01 MEZ schrieb Chris Bartolomei surfcjb@yahoo.com:

Helmut … thank you for your example however I think there is a misunderstanding of what I am trying to do. I am using GRASS on Linux (on a cluster) and the issue I am experiencing is overlaying two polygon maps (layers in Arc-speak). Points and lines on top of ONE set of polygons works fine as you have shown, however using two or more polygon maps (layers) does not seem to work. I attached an example of what i am trying to achieve: Take for instance a polygon representing Italy and you wanted it colored dark gray, then you want to overlay on top of that an administrative map showing only the areas of Lazio and Liguria colored in blue but no other administrative areas. The result would look like the Italy_sample.png file i attached (I made is using ArcPro as i am not in the office with access to our cluster). This is what is not working using the d.mon=png, d.vect tools. Could you please try something similar and see if it works for you (on linux)?
v/r
Chris

On Tuesday, March 2, 2021, 2:38:45 PM EST, Helmut Kudrnovsky hellik@web.de wrote:

I don’t see anything immediately wrong. Maybe it is a specific MS

Windows issue I cannot reproduce here in GNU/Linux.

@Helmut any ideas ?

tested here in the following way in OSGeo4W-winGRASS 7.8.5

(1) changing the working directory via GUI > change working directory

cd “D:\temp\testgrassrender”

Working directory changed to:

“D:\temp\testgrassrender”

(2) in OSgeo4W-winGRASS-windows console (no msys needed!), also change here to the new wd:

C:>cd D:\temp\testgrassrender

C:>d:

(3) put the variables and d.-commands into a bat-file into the working directory (D:\temp\testgrassrender\mytest.bat):

REM start of the batch file

set GRASS_RENDER_IMMEDIATE=png

set GRASS_RENDER_WIDTH=640

set GRASS_RENDER_HEIGHT=480

set GRASS_RENDER_TRANSPARENT=true

set GRASS_RENDER_TRUECOLOR=true

set GRASS_RENDER_FILE_COMPRESSION=0

set GRASS_MESSAGE_FORMAT=plain

set GRASS_RENDER_FILE_READ=TRUE

g.region vect=census_wake2000

d.vect map=census_wake2000 fill_color=none

d.vect map=roadsmajor color=255:0:0:255

d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10

REM end of the batch file

=> see here: in order to set a variable in the windows world, use e.g. set GRASS_RENDER_IMMEDIATE=png instead if export GRASS_RENDER_IMMEDIATE=png in the *nix world

(4) start your batch file in the windows command line:

D:\temp\testgrassrender>mytest.bat

D:\temp\testgrassrender>set GRASS_RENDER_IMMEDIATE=png

D:\temp\testgrassrender>set GRASS_RENDER_WIDTH=640

D:\temp\testgrassrender>set GRASS_RENDER_HEIGHT=480

D:\temp\testgrassrender>set GRASS_RENDER_TRANSPARENT=true

D:\temp\testgrassrender>set GRASS_RENDER_TRUECOLOR=true

D:\temp\testgrassrender>set GRASS_RENDER_FILE_COMPRESSION=0

D:\temp\testgrassrender>set GRASS_MESSAGE_FORMAT=plain

D:\temp\testgrassrender>set GRASS_RENDER_FILE_READ=TRUE

D:\temp\testgrassrender>g.region vect=census_wake2000

D:\temp\testgrassrender>d.vect map=census_wake2000 fill_color=none

d.vect komplett.

D:\temp\testgrassrender>d.vect map=roadsmajor color=255:0:0:255

d.vect komplett.

D:\temp\testgrassrender>d.vect map=schools_wake fill_color=0:128:0:255 icon=basic/circle size=10

d.vect komplett.

(5) see attached the result png - it looks like the same as Moritz’s example

kind regards

Helmut