in order to create a world wide tiles (for a basemap) in acceaptable zoom level one must have a huge hd (see in this post). but, most of the world is sea...

so i want to create x levels of the whole world (x is small say 5-10) and then y levels of only the mainland (y is big say 20) and by that save allot of cpu time for the tile creatiion and hd space for saving unneeded tiles.

i use tilemill to create tiles and you can only define a bounding box rectangle.

can anyone recommend a solution (or maybe a different approach?)


edit: the tiles are created from osm data

4 Answers 4


For lower zoom levels, I decided to take the NASA Blue Marble as tile source.

The original is downloadable here: http://visibleearth.nasa.gov/view.php?id=57752

For zoom levels 0 to 4, I took the small one and made the tiles with gdal2tiles:

gdal2tiles --s_srs EPSG:4326 --zoom 0-4 D:\Karten\Geotiff\BlueMarble\bluemarble.tif D:\Tiles\test

Fro zoom level 5 to 7, I took the high-resolution of half the world:

gdal2tiles --s_srs EPSG:4326 --zoom 5-7 D:\Karten\Geotiff\BlueMarble\bluemarble-ost.tif D:\Tiles\test

Gdal2tiles needs a little patch to use the OSM-like tile naming. I described the workflow here: GDAL2Tiles: MapTiles from BSB/KAP are Switched

You only have to do that once, as the world does not change much looking at low zoom levels.

My OSM tiles built with Mapnik start at zoom level 8. This can be defined in generate_tiles.py

To save disk space, I wrote a little recursive batch file to delete empty tiles:

for /R .\ %%N IN (*.PNG) DO if %%~zN LSS 120 del %%N

This works for Windows, you have to test which file size in bytes is best for you.


Another choice is to set up a bunch of bounding boxes covering the coastlines in a better way than one single bounding box does. This will save creation time as well.

enter image description here

  • thanks! just to be sure i understood - you delete tiles based on their size on disk. if they are smaller then x you assume they have not much data inside them? but then you delete also tiles that are on land, e.g in the desert? and that also mean you create all the tiles in the first place and then delete?
    – dowi
    May 11, 2014 at 7:48
  • I live far away from deserts and oceans ;-) My tilesets are mostly transparent to overlay on other base tiles, so it makes no difference if there is nothing in a desert or nothing on sea. I create the tiles grouped by different bounding boxes, so I can delete empty tiles and re-use the disk space.
    – AndreJ
    May 11, 2014 at 8:00
  • :-). i meant in q that i need a way to create the tiles for a basemap. maybe it wasnt clear enough.. if i go in your road eventually i'll update! thanks allot!!
    – dowi
    May 11, 2014 at 8:17
  • My extended answer seems to be a better way for your needs.
    – AndreJ
    May 11, 2014 at 8:27

First, you need to have mapnik and its python bindings installed. I guess you do already, since you run TileMill. Make a regular mapnik style out of you cartocss with carto (npm install carto; carto -l project.mml > style.xml) Then, download this script (see the page for required dependencies).

To generate tiles for the whole world, use ./polytiles.py -b -180 -90 180 90 -z 5 10 -s style.xml: your tiles for zooms 5-10 will be put into tiles directory.

To generate tiles for a bbox, specify it with -b option. Alternatively you can create a .poly file with a polygon, or download one from http://download.geofabrik.de (select a region, then find ".poly" link): specify it in -p option.

So for tiles for land.poly the command will be ./polytiles.py -p land.poly -z 11 20 -s style.xml. Run ./polytiles.py -h for a list of all options.


I have done this before in ArcGIS: I made a fishnet of coarse and fine grids, starting at the same origin. Selected and extracted the fine grid and used the extracted fine grid to erase the coarse grid. Then merge and union with the data to be gridded.

I did some cleanup of the erased grids prior to the union, merging two half grids into one etc.. but that's not really necessary.

  • thanks allot! but how can this help with the tiles creation? maybe i didnt explained myself. i meant creating tiles for a basemap (specifically from osm data), not just a shapefile of tiles. thanks!
    – dowi
    May 11, 2014 at 6:35
  • That's done by the union (Intersect for line layers). It breaks the input data down to the tile boundaries. This is particularly good for datasets that encompass large extents as the spatial index becomes smaller and more efficient - also, the reason I was doing it was for editing in SDE, breaking a feature into smaller parts means editors can alter their portion without other users' edits overwriting theirs, which was then dissolved for delivery. May 11, 2014 at 21:53

i just found out that MBTiles format does exactly that:

Maps that cover large areas of solid color like ocean or empty land can contain thousands of duplicate, redundant tiles. As example, a tile in the middle of the pacific ocean might look like this:


At higher zoom levels this could lead to millions of solid blue tiles, all exactly the same. MBTiles solves this problem by referencing tile coordinates to raw imagery. Thousands of tile coordinates could be paired to the same raw image which drastically reduces the filesize required to serve a map of multiple zoom levels.


however, this does not shorten the rendering part itself

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.