Converting an satellite image to TMS is relatively easy, especially if you are using powerful GDAL library. GDAL has binding in Python which I will be using in this post.
- Install the OSGeo4W for windows. For linux, you can use OSGeoLive which has everything that OSGeo4W has. For more information on linux equivalent to OSGeo4W, see this stackoverflow post.
- Open up the OSGeo4W shell and type
o-helpto see the list of commands that can be used with the OGR/GDAL binding.
- We will be using gdal2tiles to convert image into tiles. An imagery can be available in different format. Normally a single image as TIF or GeoTIF and mosiac of images as VRT (Virtual Raster Tables) . VRT can be use to store information to generate layers or can be used to mosaic multiple data in one. You need to convert VRT as one using gdal_merge.
- Minimal thing you need is an input file to the
gdal2tiles -z 1-21 C:\data\JIL-PHU-PAN.tif C:\xampp\htdocs\TMS
where I specified the tiles to be generated for from zoom level 1 to zoom level 21. JIL-PHU-PAN.tif is my input file and TMS is the output directory.
- You can use these tiles for various purpose. One purpose is using in Web Mapping Application. If you look inside the folder for TMS, you can find file named
openlayers.htmlwhich you can double click to view in browser (picture below).
- Another interesting example is utilizing these tiles in OpenStreetMap to digitize. If you have web server like xampp, copy the folder to the document root. Get your IP address. Open up the OpenStreeMap, zoom enough into your area so you can Edit with iD (in-browser editor).Type B (shortcut to Background settings), click custom and then get the URL of the TMS directory. In my case, those are at the
http://172.24.144.1:85/TMShosted on local xampp server. So the custom URL to enter will be
Now you can start using the TMS with the openstreetmap.