2

I am trying to display my bing map raster tiles in QGIS. I am using an HTML file like this, except with my own raster tiles, as described in WMS Tile Layer Example.

My own raster tiles don't have a projection, they have quad keys.

Is there a way to add this to QGIS with Python?

I am guessing it is something to do with this, but I cannot quite figure it out. Got through some documentation PyQGIS Cookbook | Raster Layers but with not much success.

My data is currently stored on S3, I have tried this:

from osgeo import gdal

xml = """<GDAL_WMS>
    <Service name="VirtualEarth">
           <ServerUrl>
                  https://s3.amazonaws.com/bucketname/key/t_${quadkey}.png
           </ServerUrl>
    </Service>
    <MaxConnections>4</MaxConnections>
    <Cache/>
</GDAL_WMS>"""

vfn = "/vsimem/bing.xml"
gdal.FileFromMemBuffer(vfn, xml)
rasterLyr = QgsRasterLayer(vfn, "sm")
rasterLyr.isValid()
QgsProject.instance().addMapLayers([rasterLyr])
  • Bing tiles are not a WMS and so won't load using the WMS driver – Ian Turton Sep 20 at 18:47
  • Do you know if there is another way to do it? – ajmcgraw Sep 20 at 20:43
1

This ended up working with XYZ tiles.

I just put it in like this, https://s3.amazonaws.com/bucketname/key/b_{q}.png and it worked

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.