[GIS] How to use QGIS tile server provider with local TMS folder

qgistile-map-service

I just learned that QGIS 2.18 has a Tile Server (XYZ) provider in the Browser Panel. I created a large tile map using gdal2tiles and I'm trying to load it. However, I'm not publishing the tiles through a web server instead, I though about reading the files strait from the disk. So, in the Tile Server url I used file:///I:/SUL/rapid_tms_utm21/{z}/{x}/{y}.png. The tiles do not load and I see the following error in the log panel: Tile request max retry error. Failed 3 requests for tile 13 of tileRequest 2 (url: file:///I/SUL/rapid_tms_utm21/6/19/38.png).

So, the questions are:

  1. Does QGIS Tile Server provider works with local files?
  2. Can I use the file:/// protocol? How?

I tried the following lines as the TMS Server address:

  • file:///I:/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • file:///I/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • I:/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • I/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • /I/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • /I:/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • file://I:/SUL/rapid_tms_utm21/{z}/{x}/{y}.png
  • file://I/SUL/rapid_tms_utm21/{z}/{x}/{y}.png

And the tiles work using the TileLayerPlugin

Best Answer

For use of a local Apache Server from the ms4w package, I installed MS4w into C:\ms4w\ and stored the tiles folder structure beneath C:\Tiles\.

Then I edited the file C:\ms4w\Apache\conf around line 252 to change the DocumentRoot to:

DocumentRoot "C:/Tiles"
<Directory "C:/Tiles">

Tiles can then be accessed by something like http://localhost/{z}/{x}/{y}.png

This is rather a dirty hack, but works for me.

Related Question