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

Vaclav Petras wenzeslaus at gmail.com
Thu Nov 18 18:30:18 PST 2021


Hi Luigi,

ps.map (or g.gui.psmap/File > Cartographic Composer) is certainly an
option. You can also have a look at m.printws in addons (mentioned in the
ticket you linked), but it suffers from the same issues as the normal
display since it is using d-commands.

https://grass.osgeo.org/grass78/manuals/addons/m.printws.html

I have tried to put individual layers rendered as SVGs together manually.
That was too difficult to match, but perhaps if you clip vectors to a
computational region you can match those.

Just to be clear, are you saying the ps driver (with
GRASS_RENDER_PS_TRAILER etc) didn't work for you?

Best,
Vaclav

On Tue, Nov 9, 2021 at 9:48 AM Luigi Ponti <luisponti at tiscali.it> wrote:

> Dear list,
>
> I am replying to myself just to say that I hit the same issues as shown at:
> https://trac.osgeo.org/grass/ticket/3033
>
> My apologies for not checking that first.
>
> As I keep running into this problem, but there is not a lot of discussion
> on it, probably people have found other ways to deal with it (e.g., ps.map,
> which what I will try next).
>
> Also, I noticed that the Python way was also explored:
> https://discuss.wxpython.org/t/wx-image-postscript/25813
>
> which I was actually about to ask…
>
> Kind regards,
>
> Luigi
>
>
> On Thu, Oct 28, 2021 at 12:34 PM Luigi Ponti <luisponti at tiscali.it> wrote:
>
>> 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
>>
>>
>>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20211118/58a1936c/attachment.html>


More information about the grass-user mailing list