# using createTileMapServiceImageryProvider with gdal2tiles

**URL:** <https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351>\
**Category:** CesiumJS\
**Created:** [July 11, 2016, 5:53pm UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351 "2016-07-11T17:53:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [July 11, 2016, 5:53pm UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/1 "2016-07-11T17:53:43Z")

</div>

I think i was going about getting my geotiffs on cesium all wrong. I was insisting on using KML but I think I don’t need to do that as gdal2tiles seems to write out tms which i believe createTileMapServiceImageryProvider can help with. The problem is this:

I have a script htat processes some goe tiffs into what I thought was TMS format using gdal2tiles. The thing is when I try to create a viewer to use this info:

var l1924 = layers.addImageryProvider(new Cesium.createTileMapServiceImageryProvider({

url:‘myTiles/tiles’,

minimumLevel: 9,

maximumLevel: 14,

credit: ‘moi’

}));

I get no errors in the imagery provided layers but it does fail to load a lot of png files from the tileset. I realize the numbers are just only slightly off than the tile set I have on disk and I cannot figure out what is causing this.

So on my disk my gdal2tiles created this:

Location

**10** /66/314.png

10/66/315.png

but cesium is looking for it in the 9 directory e.g:

315.png:1 GET [http://localhost:8000/static/swsite/images/processed/Maui/kml/test/\*\*9/\*\*66/315.png](http://localhost:8000/static/swsite/images/processed/Maui/kml/test/ **9/** 66/315.png) 404 (Not Found)

315.png:1 GET [http://localhost:8000/static/swsite/images/processed/Maui/kml/test/\*\*9/\*\*67/315.png](http://localhost:8000/static/swsite/images/processed/Maui/kml/test/ **9/** 67/315.png) 404 (Not Found)

no idea why the diff or how to get them to sync up

The tilemapsource.xml file:

\<?xml version="1.0" encoding="utf-8"?\> Maui.nitf

EPSG:4326

---

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [July 11, 2016, 7:18pm UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/2 "2016-07-11T19:18:58Z")

</div>

for completeness I should say that the loading in the javascript points to myTiles/tiles folder, in reality it is the correct folders as given above that is it pointing too so:

url:

url: ‘static/swsite/images/processed/Maui/kml/test’

---

<div class="post-metadata">

**Author:** ![jbo023](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jbo023/32/2777_2.png) [@jbo023](https://community.cesium.com/u/jbo023)\
**Post date:** [July 15, 2016, 11:37am UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/3 "2016-07-15T11:37:43Z")

</div>

Hello Shane,

i think cesium uses the mercator tilingschema as a default, so your dataset which is in the geodetic profile is not working.

But you can add the following.

var l1924 = layers.addImageryProvider(new Cesium.createTileMapServiceImageryProvider({

url:‘myTiles/tiles’,

tilingScheme : new Cesium.GeographicTilingScheme(),

minimumLevel: 9,

maximumLevel: 14,

credit: ‘moi’

}));

I hope this will help you

Jannes

---

<div class="post-metadata">

**Author:** ![Shane\_Thomas](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Shane\_Thomas](https://community.cesium.com/u/Shane_Thomas)\
**Post date:** [July 15, 2016, 8:00pm UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/4 "2016-07-15T20:00:49Z")

</div>

Thank you Jannes, I did try both the code and calling

gdal2tiles.py -p mercator my.nitf

and the results were the same, cesium was looking for file names that existed in wrong folders though. I did add that snippet of code too, not sure if I did something else noticeably wrong but same result from the above methods.

Shane

---

<div class="post-metadata">

**Author:** ![bf1](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bf1](https://community.cesium.com/u/bf1)\
**Post date:** [October 7, 2017, 3:40pm UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/5 "2017-10-07T15:40:12Z")

</div>

Sorry to resurrect such an old thread, but I've been struggling with exactly the same problem. My solution was to set "geodetic" profile in gdal2tiles.py with -p, and the -d flag to set "TMS compatible".

---

<div class="post-metadata">

**Author:** ![ramtob](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ramtob/32/3476_2.png) [@ramtob](https://community.cesium.com/u/ramtob)\
**Post date:** [August 22, 2022, 10:52am UTC](https://community.cesium.com/t/using-createtilemapserviceimageryprovider-with-gdal2tiles/4351/6 "2022-08-22T10:52:10Z")

</div>

Thanks bf1,  
Your suggestion to add to gdal2tiles the flags -p geodetic and -d (or --tmscompatible) was helpful. gdal2tiles gave me quite a bit of trouble. I think it should be better documented, in the context of preparing tiles for Cesium.  
Ram
