I am trying to display (on OpenLayers 2.13) a local tiled raster I made with gdal2tiles.py. Unfortunately it's all blank or pink. Here is my layer definition:

var tiles = new OpenLayers.Layer.XYZ("Local tiles", "tiles/${z}/${x}/${y}.png", {
    isBaseLayer: true,
    displayProjection: new OpenLayers.Projection("EPSG:4326"),
    maxExtent: [-75.1729846, 39.9439032, -75.1529085, 39.9599679]


What is wrong?

Here is a link to my OpenLayers test page : http://popopopopo.voila.net/index.html

And here is the original image: http://popopopopo.voila.net/raster.tif (EPSG: 3857)

  • Welcome to gis.SE. Can you open the tiles directly? For me, it redirects in some strange way (possibly your hosting provider).
    – BradHards
    Jan 3, 2014 at 23:36
  • Yes I can open tiles directly like this popopopopo.voila.net/tiles/14/4770/10178.png if this is what you mean.
    – user25448
    Jan 4, 2014 at 8:11

1 Answer 1


Gdal2tiles numbers the tiles from South to North (according to the OGC TMS sepcification), while OSM numbers from North to South (like Google and bing does it).

I described here what I changed to make it numbering in correct (OSM) order:

GDAL2Tiles: MapTiles from BSB/KAP are Switched

If I load the OSM tile with the example numbers you gave above, I get one from the Pacific off the coast of Chile, at -75° East -39.95° North. I guess that is not what you intended with your extent, which should direct to Philadelphia.

The mapquest tiles you show in your map are in the range of


So you have to make sure your self rendered tiles have the same number if they should appear in the same place.

Leaflet has an option to set tms=true for tiles generated according to the TMS specification. Openlayers seems to lack this opportunity yet.

See also:




It is possible to use the TMS numbered tiles by extending the Openlayers TMS call, see my answer here:

Add TMS layer to OpenLayers

  • Indeed, what you say is worth to know because I didn't know it was upside down with gdal2tiles. I am now testing maptiler instead as suggested. I keep you informed if I managed to display successfully the raster...
    – user25448
    Jan 6, 2014 at 17:06

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.