I am not from the geographic field and am having issues finding the correct words to feed google, or this really hasn't been asked before.

Simply put:

  • I have a map in a bunch of KMZ files.
  • I want to cut them into tiles of different sizes so that my tile server can serve them to applications as overlays.
  • Creating an image overlay is not a solution because I receive out of memory errors on my mobile device.


The KMZ files are really ZIP files and contain 9 PNG files and 1 KML file
The PNG files are visually aligned on the map in the following manner:

A1 | A2 | A3
B1 | B2 | B3
C1 | C2 | C3

The KML file contains placement information of files A1-C3
The KMZ files do not all cover the same amount of area (some are bigger some smaller) and the placement information is not the same for all KMZ files and their contents (the top-left top-right bottom-left bottom-right are not always rectangular, they may be stretched).

I have tried stitching the images together using java commands BufferedImage and Graphics2D but have noticed that they are stretched and don't fit exactly one into the other and leave spaces between the images. I assume this is because the earth is round and I am trying to do this on a plane.

I have thought about creating a canvas and projecting the images to their lat/lng positions and then creating an image of that.

Is there a program that does the tiling for me and how do I preprocess the KMZ files so that the program can use the images?

I don't know how to proceed.

How could I go about this?


After suggestions by @nmtoken I have looked at the GDAL, specifically gdal_translate, gdal_merge.py and gdal2tile.py

I created a script that unzips the KMZ to KML+PNG, then read the north, east, south and west positions from the KML for each PNG and uses those to create the geotiffs using gdal_translate. I used the -separate rgba option so the color palette would be preserved when merging later on. Then I used gdal_merge.py to merge all the geotiffs into one big file. Next I used gdal2tile.py to create tiles with pixel size 256X256 that I can use as a map source in a google map viewer. Since the TMS (tile mapping system) that google uses does not comply with the standard, I had to adjust the Y value when retrieving the tile path. There is a very helpful article that explains how to adjust the Y value in JavaScript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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