-1

If a person uses the text only version of grass on a remote system, how do you output the legend as a graphics file?

such as: r.out.tiff input=mymap output=file.tiff

but have it print the legend as well, or even just the legend itself.

d.legend does not work becuase there is no xwin etc..

1
  • 1
    Please replace your ALL CAPS title with mixed case by using the edit button beneath your question.
    – PolyGeo
    Commented Sep 22, 2015 at 20:10

2 Answers 2

1

You can use e.g. d.rast.legend for this when using the PNG driver as display output. All display commands can write to the PNG driver, i.e. output into that file.

1

Thank you MarkusN :)

It took me awhile to figure out your solution, but for those that may have a similar issue, they may find what I used, with your advice, to be helpful :)

Within the Bash script that calls GRASS, I did the following:

# First call the PNG driver to use as "Monitor" since it is a 
# remote system without a display to use

export GRASS_PNGFILE=yourfile.png
export GRASS_RENDER_TRUECOLOR=TRUE # if needed, if not it will default to "False"
export GRASS_WIDTH= your value in pixels eg. 800
export GRASS_HEIGHT= your value in pixels eg. 600
d.mon start=PNG
# Below is what tells GRASS to plot the legend! :)
d.rast.leg rast=RasterName map=MapName num_of_lines=How many colors are your ramp
d.rast rastname (to plot the map with the legend)
# d.vect somevectormap (to use if your map is vector instead of raster)
d.mon stop=PNG  # Here we close the PNG driver

# After the file is plotted, make sure grass uses
"d.erase -f" # to clear your driver, if not run it yourself :)

Thanks again MarkusN for your guidance :)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.