2

Its great that you can now use TMS layers in qgis! Only, my result is broken. At the 3 highest resolution zoom levels it looks perfect, but at lower resolution layers, i get mixtures of tile shift, black tiles, bright noise colors, etc.

Heres examples of lower zoom (nb: vectors are seperate layers). pic http://zoneblue.org/files/qgis-tms.jpg

Im using qgis 2.4.0. Here is my xml:

<GDAL_WMS>
    <Service name="TMS">
        <ServerUrl>file:///E:/gis/tilesets/ortho/${z}/${x}/${y}.jpg</ServerUrl>
        <SRS>EPSG:2193</SRS>
        <ImageFormat>image/jpeg</ImageFormat>
    </Service>
    <DataWindow>
        <UpperLeftX>1678531.2</UpperLeftX>
        <LowerRightY>5636060.0</LowerRightY>
        <LowerRightX>1703824.0</LowerRightX>
        <UpperLeftY>5669442.4</UpperLeftY>
        <TileLevel>9</TileLevel>
        <YOrigin>bottom</YOrigin>
        <SizeX>63232</SizeX> 
        <SizeY>83456</SizeY>
        <TileCountX>247</TileCountX> 
        <TileCountY>326</TileCountY>
    </DataWindow>
    <Projection>EPSG:2193</Projection>
    <BlockSizeX>256</BlockSizeX>
    <BlockSizeY>256</BlockSizeY>
    <BandsCount>3</BandsCount>
</GDAL_WMS>

The tileset has 0-9 levels, 0-246 for the folders, 0-325 for the files. 0.4m per px imagery. Everything is transverse mercator.

You just make a xml file with the above in it, add a raster layer with it, and its done. Note that the pixel size and coordinate extents must be for the whole tiles, not just your data extent.

Anyway am i doing something wrong, or is this a bug?

I have read and reread the gdal minidriver spec here, but its not very detailed. http://www.gdal.org/frmt_wms.html

  • I would try 0 as TileLevel. Documentation calls it "highest resolution" but perhaps it means the opposite, biggest pixel size. – user30184 Sep 23 '14 at 22:17
  • If i do that qgis kind of hangs, progress indicator stalls, 50% cpu use. Not sure what its doing, or whether it will complete. It might have something to do with the gdal minidriver using local tms files not properly reporting non existant files. See gis.stackexchange.com/questions/81114/… – Peter Sep 23 '14 at 23:02
  • How did you create the tiles? Can you advice an easy way to reproduce? – user30184 Sep 24 '14 at 4:24
  • The tileset was made using maptiler/gdal2tiles. I tried in on two different tilesets and got the same result. The first had zooms 0-9, the second 0-7, both with simalar extents. I took a big geotiff, ran it through maptiler. Took the known extents in the native crs, plugged them into the gdal wms xml, and loaded that as a layer in qgis using add raster layer. You can make a vrt from the xml, and add that as a layer but get exactly the same result. Im fairly confident i have the extents right, because at full zoom, the tms layer aligns with the vector layers pefectly. – Peter Sep 24 '14 at 23:45
  • Sorry in case it needs clarifying the tileset works perfect at all zoom levels in openlayers. And the srs is NZTM epsg:2193 which is a meter based transverse mercator. – Peter Sep 24 '14 at 23:49
1

Been bashing my head against the same problem, and this is the solution I found.

The issue (for me) was caused by incorrect handling of 404 Not Found responses, and was more prevalent zoomed out as QGIS was trying to load tiles outside the scope of my TMS tilestack.

Adding the following line to the .xml file (in the outermost "GDAL_WMS" level) solved it:

<ZeroBlockHttpCodes>204,404</ZeroBlockHttpCodes>

This forces 404 responses to be treated as black tiles rather than interpreted as images (which is what was happening). Not sure why this was also affecting the tiles that did exist in the TMS and were loaded correctly, but it did.

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.