[GRASS-dev] Render related environment variables and vector maps

nik at nikosalexandris.net nik at nikosalexandris.net
Fri Dec 18 09:40:44 PST 2020


Dear 'GRASS_RENDER'-experts,

I use custom functions to render several raster maps on the same output 
image file (always in the Terminology terminal):
```
# draw a raster map using `tyraster`
function tyraster {
     # new frame, new file
     unset GRASS_RENDER_FRAME
     unset GRASS_RENDER_FILE_READ
     export GRASS_RENDER_FILE="${GRASS_RENDER_PATH}/$1".png
     # keep 'last' filename
     export LAST_GRASS_RENDER_FILE="$GRASS_RENDER_FILE"
     d.rast "$@"
     echo "$GRASS_RENDER_FILE"
     tycat -g 1000x1000 "$GRASS_RENDER_FILE"
     # reset default filename, make it reusable
     export 
GRASS_RENDER_FILE="${GRASS_RENDER_PATH}/${GRASS_RENDER_FILENAME}.${GRASS_RENDER_FORMAT}"
     export GRASS_RENDER_FILE_READ=TRUE
}

# then, draw on top of the existing (output) image file with 
`tyraster.add`
function tyraster.add {
     # use 'last' filename
     export GRASS_RENDER_FILE="$LAST_GRASS_RENDER_FILE"
     d.rast "$@"
     echo "$GRASS_RENDER_FILE"
     tycat -g 1000x1000 "$GRASS_RENDER_FILE"
     # reset default filename
     export 
GRASS_RENDER_FILE="${GRASS_RENDER_PATH}/${GRASS_RENDER_FILENAME}.${GRASS_RENDER_FORMAT}"
}
```

The same approach does not work for vector maps with PNG as an output 
file format (substitute in the above functions `d.rast` with `d.vect`).
It does work, however, with the BMP file format.

Would anyone have a clue why PNG is 'problematic' with vector maps?
Each time `d.vect` is called with GRASS_RENDER_FILE_READ=TRUE, there is 
no data rendered in the output image file.
Unsetting GRASS_RENDER_FILE_READ will draw data in the pre-defined 
output image file, however without drawing it on top of existing data -- 
which is the point of `tyraster.add` and a corresponding custom function 
`tyvector.add`.

I use the following setup (of which some variables are custom ones):
```
export GRASS_RENDER_PATH=/some/path/grassdb/render
export GRASS_RENDER_FILENAME=grass_render_file
export GRASS_RENDER_FORMAT=bmp
GRASS_RENDER_FILE="${GRASS_RENDER_PATH}/${GRASS_RENDER_FILENAME}.${GRASS_RENDER_FORMAT}"
export GRASS_RENDER_FILE

export GRASS_RENDER_FILE_READ=TRUE
export GRASS_RENDER_FILE_MAPPED=TRUE
export GRASS_RENDER_DRIVER=cairo
export GRASS_RENDER_ANTIALIAS=CAIRO_ANTIALIAS_SUBPIXEL
GRASS_RENDER_IMMEDIATE="${GRASS_RENDER_DRIVER}"
export GRASS_RENDER_IMMEDIATE

export GRASS_RENDER_TRUECOLOR=TRUE
export GRASS_RENDER_BACKGROUNDCOLOR=000000
export GRASS_RENDER_TRANSPARENT=TRUE

export GRASS_RENDER_WIDTH=1500
export GRASS_RENDER_HEIGHT=1500
export GRASS_RENDER_LINE_WIDTH=1

export GRASS_FONT=DroidSans
export GRASS_RENDER_TEXT_SIZE=10
```

Thank you, Nikos


More information about the grass-dev mailing list