Sunday 26 August 2018

open source gis - Is there a Python Lib for requesting WMS/WFS and saving as image/PDF?


i am wondering whether there's Python open-source GIS lib which has APIs to support call WMS/WFS from another GIS server (e.g., GeoServer) and then save the response data(WMS Basemap and WFS layer) as pictures.


any recommendations?


thanks for any inputs!



UPDATE:


what I am trying to do is a Map Printing service, by using OpenLayers as the front-end and Django as the server; Client user set the extent and layers and then send the print request (which refers to the parameters, i.e., map extent, names of layers) to server, then server takes over this request and call WMS/WFS again by using request parameters, save the response as PDF, export this PDF link to client.


The difficult part is that how the server call WMS/WFS and combine/overlay these responses together (i.e., put these map/layers together, since WMS is usually the base map, WFS points to the feature layers), finally save this combined object as Image.


in current answers, urllib seems a good one, but i am not sure how to combine these responses (WMS, WFSs) together; OWSLib also seems another good option, but it indicates it's a client programming tool, I am a little confused that whether it's appropriate for my use...


any other further inputs???


appreciate!



Answer



There is OWSLib which should provide exactly what you need.



OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.



OWSLib provides a common API for accessing service metadata and wrappers for numerous OGC Web Service interfaces.



Documentation and examples here. Client in this context means it is a client application to a WMS/WFS server - it can be run on a server if required.


After you added more details to your answer it looks like the MapFish print application fits your needs exactly. It is a Java application that can be integrated with OpenLayers and stitches tiles, WMS, WFS etc. together and produces a PDF.


As it is a command line application it can be manipulated with a Python wrapper. See following links for more details:


http://geographika.co.uk/mapfish-print-module-for-iis


https://github.com/amercader/MapFish-Print-IIS


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...