[GRASS-user] d.mon start=cairo multi-layer PDF, PS, SVG output

Luigi Ponti luisponti at tiscali.it
Thu Oct 28 03:34:42 PDT 2021


Dear all,

I am trying to get output image files in various formats using the Cairo
driver, following some very useful Python scripting examples:
https://baharmon.github.io/python-in-grass

When I try to map vector layers (e.g., point data) on top of raster layers
(say a digital elevation model);

if I use PNG output file extension, both vector and raster layers show up
with points having transparent background,

if I use PDF, PS, or SVG output file extension, only the vector layer
(drawn last) is shown in the output image with white background.

Maybe the PS driver is a better option?

Yet, I was reading this old grass-dev post that may be relevant:
https://marc.info/?l=grass-dev&m=146346954429631&w=2

Kind regards,

Luigi


Sample test function I am using follows:

def make_map(outfile_name,
fig_width,
fig_height,
bg_color: Optional[str] = None,
file_types: Optional[list] = None):
""" Test ouput map figure.
PLEASE CHECK as PDF and PS output does not get vectors displayed on
top of rasters. """
background_color = bg_color or [NO_BG_COLOR]
extensions = [PNG] if file_types is None else file_types
for extension in extensions:
outfile = pathlib.Path(OUT_DIR).joinpath(f"{outfile_name}.{extension}")
grass.run_command("d.mon", overwrite=True,
start="cairo",
width=fig_width,
height=fig_height,
bgcolor=background_color,
output=outfile)
grass.run_command("d.rast",
map="raster_layer")
grass.run_command("d.vect",
map="point_vector_layer",
type="point",
color="150:0:0",
size=20)
# all other display commands
grass.run_command("d.mon", stop="cairo")


Bundled GRASS app for Mac from here:
http://grassmac.wikidot.com/downloads

System Info:

GRASS version: 8.0.dev

Code revision: 32930185c

Build date: 2021-07-01

Build platform: x86_64-apple-darwin20.5.0

GDAL: 3.1.4

PROJ: 7.1.1

GEOS: 3.8.1

SQLite: 3.35.4

Python: 3.8.8

wxPython: 4.1.1

Platform: macOS-10.16-x86_64-i386-64bit


g.version -b
GRASS 8.0.dev (2021)

 ./configure
 --with-macosx-sdk=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
--enable-64bit --with-macosx-archs=x86_64 --with-opengl=aqua --with-openmp
--prefix=/Applications/GRASS-8.0.app/Contents/Resources --with-freetype
--with-freetype-includes=/Applications/GRASS-8.0.app/Contents/Resources/include/freetype2
--with-freetype-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-gdal=/Applications/GRASS-8.0.app/Contents/Resources/bin/gdal-config
--with-gdal-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-proj=/Applications/GRASS-8.0.app/Contents/Resources/bin/proj
--with-proj-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-proj-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-proj-share=/Applications/GRASS-8.0.app/Contents/Resources/share/proj
--with-geos=/Applications/GRASS-8.0.app/Contents/Resources/bin/geos-config
--with-jpeg-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-jpeg-libs=//Applications/GRASS-8.0.app/Contents/Resources/lib
--with-png-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-png-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-tiff-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-tiff-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-postgres=yes
--with-postgres-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-postgres-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--without-mysql --with-sqlite
--with-sqlite-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-sqlite-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-fftw-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-fftw-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-cxx --with-cairo
--with-cairo-includes=/Applications/GRASS-8.0.app/Contents/Resources/include/cairo
--with-cairo-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-cairo-ldflags=-lcairo --with-zstd
--with-zstd-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-zstd-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-bzlib
--with-bzlib-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-bzlib-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-netcdf=/Applications/GRASS-8.0.app/Contents/Resources/bin/nc-config
--with-blas
--with-blas-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-blas-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-lapack
--with-lapack-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-lapack-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-netcdf=/Applications/GRASS-8.0.app/Contents/Resources/bin/nc-config
--with-nls --with-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-includes=/Applications/GRASS-8.0.app/Contents/Resources/include
--with-pdal=/Applications/GRASS-8.0.app/Contents/Resources/bin/pdal-config
--with-pdal-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-readline
--with-readline-includes=/Applications/GRASS-8.0.app/Contents/Resources/include/readline
--with-readline-libs=/Applications/GRASS-8.0.app/Contents/Resources/lib
--with-liblas=/Applications/GRASS-8.0.app/Contents/Resources/bin/liblas-config


-- 
Luigi Ponti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20211028/b913739b/attachment-0001.html>


More information about the grass-user mailing list