1

Currently I have some data in PostGIS. I want to implement the following: users will make a request via web, with parameters like location, scale, layers to be displayed, etc. and I need to provide them with maps in PDF format. The layout of these maps will contain the map itself as well as common cartographic elements like scale bar, north symbol, legend, date, title, etc.

I was looking to Mapnik to render the PDFs. The problem then is how to render the layout (dynamic, since the layers, scale, date...will vary).

What open-source package with Python bindings (or other solution) would you recommend for doing this (I'm looking at QGIS right now)?

I am looking for an alternative to the Esri arcpy.mapping module.

3
  • Are you looking for something like the print functionality in sogis1.so.ch/wsgi/…
    – underdark
    Dec 8, 2014 at 20:04
  • Yes, underdark, that is exactly what I need. I had stumbled upon that website when looking for a solution. As it stands right now, I'm looking at using Mapnik to render an image, having a PDF file pre-authoured, and then using Reportlab to update the PDF with the dynamic data.
    – Jordi
    Dec 9, 2014 at 16:49
  • That page used QGIS Server's getPrint request. It returns a PDF based on a QGIS print composer template
    – underdark
    Dec 9, 2014 at 19:33

1 Answer 1

1

I have been working on something similar. You can probably use the mapnik printing module for most of the things you need (scale, legend, etc.). You will probably have to tweak it a little bit to get the design you want. Have a look at render_legendand render_scalein particular.

Here is the link to the module on GitHub: https://github.com/mapnik/python-mapnik/blob/master/mapnik/printing.py

1
  • Thank you thieumap. I will look into them. I ended up drawing the scale bar with the Reportlab module. It works very well with a limited number of possible map scales, like our case is. Another possibility that we have not implemented is to pre-author the scale bar images (with a CAD software, for instance), and then past them in the PDF document with Reportlab. We currently do that for the legend. They are not elegant solutions but it serves our current needs.
    – Jordi
    Jun 6, 2016 at 16:09

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.