8

I've been searching for a way to generate server side static maps using Python (or any other languages, doesn't matter).

I can create the maps I want with QGIS (and they look really great) but I don't know how to automate the process.

What I want is;

  • Creating a map style in QGIS and export it to some kind of XML (there is a plugin named quantumnik but it is not available any more I guess)

  • Running a query over PostGIS in my Python script

  • Creating a shapefile or only a PNG using the dataset returned from query and style XML defined above.
  • Repeating the whole process every night with different datasets.

I've played around with Mapnik but couldn't succeed in generating a heatmap yet (https://github.com/stellaeof/mapnik-rasterizers)

I've read about QGIS server, GeoServer, MapServer. But now I am confused since there are a lot of tools around.

  1. Is Mapnik the right direction or are there any better tools for that kind of process?

  2. Or is there a way to use QGIS programmatically on a server?

EDIT:

After trying a lot of different things, I've decided to use GeoServer. I've installed it using using docker container image: https://github.com/kartoza/docker-geoserver It can generate png, gif, jpeg, and also can serve WMS layers that can be integrated with Leafletjs pretty easily.

Only problem is, I am trying to design my maps with QGIS first and then export them to GeoServer using "Geoserver Explorer" plugin and it doesn't work well for labels and some other features. There is no easy way to generate SLD in QGIS I guess. I keep fixing SLD configurations by hand after exporting them to GeoServer. But this is still the best solution I guess.

It would still be great if you can suggest better plugins or ways to integrate QGIS and GeoServer or any other SLD editors.

  • From painful personal experience I'm using the exact process you describe (creating SLD in QGIS then changing manually to fit geoserver) on an almost weekly basis. Managed to automate some of the fixing through scripts on the geoserver, but not ideal. – Phil G Nov 10 '16 at 15:13
  • There is SLDEditor github.com/robward-scisys/sldeditor/wiki/userguide or both QGIS and GeoServer will accept contributions or cash to fix issues if they matter to you – Ian Turton Jul 5 '17 at 16:32
1

Yes, it is complicated, and partially because of there many moving pieces in the process. I've done something similar using Python and Mapnik. Below is the step by step procedure:

1) A python script downloads the data from the server (scattered weather station data in this case). 2) A bash script executes gdal_grid that interpolates the data and write a GeoTIFF file. 3) A bash script run generate_tiles.py using a predefined mapnik style file and the GeoTIFF to create all tiles. 4) A web app using OpenLayers + TMS layer consume those tiles.

Hope it helps. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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