I want to overlay tiles generated from a GeoTIFF raster I created on a google satellite map. What I have tried is:

  1. Style and output a high quality colored PNG using qgis's map composer
  2. Tile this PNG using gdal2tiles.py
  3. Use leaflet to point to these generated tiles

This is simple and works well, result is:

enter image description here

Since I want to have a "swipe" functionality to contrast my custom tiles with googles satellitle map, my tiles must be spatially aligned with googles product and have transparency where I indicate. I have not found a way to properly do this. Could someone propose a way to do this correctly?

1 Answer 1


You would probably be interested in Leaflet.Control.SideBySide plugin, it provides that exact functionality (demo).

screenshot of Leaflet.Control.SideBySide plugin

However, it assumes that your tiles already perfectly match.

I do not know unfortunately how you can specify in gdal2tiles a Z, X, Y offset. But you might be interested in that post: Specifying Lat & Long for Leaflet TileLayer. Note that modifying the tile numbers on the fly should work, but you may still have some offset if your image was not aligned with Google Maps tiles when performing the tiling operation.

  • Thats's exactly what I want to know. To have them (google vs my tiles) match, all I need is EPSGs to be the same at the moment of tiling? A grand problem is that PNGs are not really georeferenced as is. So I think an additional step is needed to produce a colored image which can be tiled appropriately.
    – JEquihua
    Jan 7, 2016 at 19:44
  • If you can skip the PNG step, or convert it back to GeoTIFF (with embedded georeferencing), it sounds like gdal2tiles should generate the appropriate Z/X/Y tile numbers right away (when specified the appropriate SRS)? See gis.stackexchange.com/questions/34198/…
    – ghybs
    Jan 7, 2016 at 19:53
  • Yes, Z/X/Y is generated fine, the problem is the georeferencing of the coloured image. In the link you posted they show that a TIFF can have associated spatial metadata but I'm not sure as to how to Style GeoTIFF (e.g. in QGIS) and then save as a high quality georeferenced TIFF.
    – JEquihua
    Jan 7, 2016 at 19:59
  • I see, so your issue is just in the last alignment, "within a tile"? In the end of the linked question, the OP shows a "solution" which converts a PNG into GeoTIFF with desired georeferencing of the image corners. Would that work for your case? Or still a different issue?
    – ghybs
    Jan 7, 2016 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.