QGIS – Opening Local TMS in QGIS Using GDAL

gdalqgistile-map-service

I created a TMS using gdal2tiles command. The tiles where generated correctly and I can see them using the leaflet and openlayers html pages also created by gdal2tiles. Now, I'm trying to open the TMS in QGIS, using gdal and the TMS mini driver.

I created the xml file describing the TMS but when I load it in QGIS, I get a blank screen with some random colored pixels on the top part of the screen. Any Idea what could be wrong? I'm using QGIS 2.18.0, 64bis from OsGeo4W (windows 10).

Bellow is my XML file:

<GDAL_WMS>
<Service name="TMS">
    <ServerUrl>./${z}/${x}/${y}.png</ServerUrl>
    <ImageFormat>image/png</ImageFormat>
</Service>
<DataWindow>
    <UpperLeftX>-20037508.34</UpperLeftX>
    <UpperLeftY>20037508.34</UpperLeftY>
    <LowerRightX>20037508.34</LowerRightX>
    <LowerRightY>-20037508.34</LowerRightY>
    <TileLevel>14</TileLevel>
    <TileCountX>1</TileCountX>
    <TileCountY>1</TileCountY>
    <YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:3857</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>4</BandsCount>
<DataType>byte</DataType>
<ZeroBlockHttpCodes>204,303,400,404,500,501</ZeroBlockHttpCodes>
<ZeroBlockOnServerException>true</ZeroBlockOnServerException>
<Cache/>
</GDAL_WMS>

Best Answer

It might be necessary to add a protocol (http://localhost/ or file:///) to the serviceURL. See GDAL TMS (WMS) mini driver for an example.

As an alternative, you can use the TileLayer plugin, which can deal with local tiles with this syntax:

 myMapnik   myMapnik    file:///F:/Tiles/myMapnik/{z}/{x}/{y}.png   1   0   15  -180    -85.0   180.0   85.0

The plugin expects a file with TAB delimiters.