0

We are trying to develop a workflow to generate .mbtiles (for offline tiled map viewing) from a QGIS project.

A few years back, in QGIS 2.4, we went with QGIS -> multiple tiffs -> multiple GeoTIFFs -> VRT -> tiles. That introduced some image quality loss. See that question here.

Even back then, it seemed the real way to get around image quality loss would be to use QGIS server and download the tiles that it serves up. It was over my head and I did not make any attempts along those lines.

Now, QGIS 3.4 serves WMTS so the serve-and-download method seems to be more feasible. I set up WAMPServer (Windows 10) and QGIS Server (3.4), and I am getting pretty close but am not having luck finding a good way to grab all the tiles served up by QGIS server.

I can grab the entire map image of a simple locally-served map using WMS:

http://localhost/cgi-bin/qgis_mapserv.fcgi.exe?MAP=D:\Documents\GIS\Projects\serverTest.qgz&SERVICE=WMS&REQUEST=GetMap&WIDTH=400&HEIGHT=200&CRS=EPSG:4326&LAYERS=Community_Boundaries

I can grab one tile using WMTS:

http://localhost/cgi-bin/qgis_mapserv.fcgi.exe?MAP=D:\Documents\GIS\Projects\serverTest.qgz&SERVICE=WMTS&REQUEST=GetTile&Version=1.0.0&Style=default&TileMatrixSet=EPSG:4326&TileMatrix=1&Format=image/png&Layer=CommBnd&TileRow=1&TileCol=1

(At the moment, that is serving up a solid black 256x256 image even though the full WMS map looks correct with a few town boundaries, but, I will figure that out separately.)

What's the best way to grab a full tile set or mbtiles file based on the WMTS single-tile request above?

  • Have you ever tried mapproxy and you can seed your cache as mbtiles and use it offline as xyz tiles. github.com/kartoza/docker-mapproxy – kartoza-geek Nov 20 '18 at 20:09
  • I haven't tried mapproxy, that looks like an complete possible solution - but it seems like there should be something simpler, that just makes the requests and builds a file. PortableBasemapServer is one that would probably work. It seems that downloading is a client-side solution, where seeding is a server-side solution? Either way would work - just seems like client-side would be simpler? – Tom Grundy Nov 20 '18 at 20:42
  • If you use docker deploying mapproxy is quite easy and you also get the added advantage of meta tiling which QGIS server does not natively support. There are a lot of advantages of using mapproxy ie with regards to how your labels will appear, doing concurrent requests and not overloading your server – kartoza-geek Nov 20 '18 at 22:10
  • metatiles would be great - I definitely have the chopped-labels problem due to single-tiles-only in the mbtiles I had created previously. Does mbtiles have any concept of / capability for metatiles, or, is metatiles a concept that only pertains to dynamically generated (served) content? I can't find an easy answer to that question online. – Tom Grundy Nov 21 '18 at 0:16
  • Mapproxy supports metatiling. You can choose what kind of cache you need to store your tiles as. Mbtiles is one of them and all the tiles that will be generated and cached as mbtiles will not have any problem with chopped labels as they will be generated with the tiling. Can you look at github.com/kartoza/docker-mapproxy/pull/4 to run a sample example and see how to use the mbtiles cache – kartoza-geek Nov 21 '18 at 5:28

Your Answer

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

Browse other questions tagged or ask your own question.