12

I have about 600 GeoTIFF map files, each about 140 mb in size that I'd like to convert to KMZ files so people can download them and use them with Garmin GPS units, Google Earth, etc.

Anyone know an easy way to batch process these, preferably converting the tiff image to a much smaller jpeg image as part of the process?

I've stumbled upon gdal_translate which I guess might be useful optimising the images into something smaller using the "-co COMPRESS=JPEG" option.

5
  • Looks like G-Raster might let me do the process file-by-file.
    – Gavin
    Dec 29, 2011 at 3:39
  • Global Mapper looks capable too, but is a bit expensive as I'm not going to be profiting from people downloading the KMZ files.
    – Gavin
    Dec 29, 2011 at 3:51
  • OkMap produces good output, but again lacks that useful batch processing option.
    – Gavin
    Dec 29, 2011 at 10:27
  • 1
    if the images are that big you must not only tile them in maximum 1 megapixels, you also must not exceed 100 tiles within the same KMZ in order for Garmin handhelds to accept it as a custom map. It must also be in WGS84 lat long. See garmin forum for more details on Garmin KMZ support.
    – Stefan
    Jan 10, 2012 at 9:53
  • In the end I completed the process manually using OkMap. Thanks for everyone's input.
    – Gavin
    Jan 10, 2012 at 21:10

6 Answers 6

16

Recent versions of gdal_translate have support for KML Superoverlay. Although it is not yet documented on the GDAL website the following can be used:

gdal_translate.exe -of KMLSUPEROVERLAY c:\in.tif c:\out.kmz -co FORMAT=JPEG

This will save a tiled version in a kmz file using jpeg compression.

On windows you can automate using

forfiles /m *.tif /c "cmd /c gdal_translate.exe -of KMLSUPEROVERLAY @FILE @FNAME.kmz -co FORMAT=JPEG"

This assumes that the input files are in WGS84.

7
  • 1
    Unfortunately I've just discovered that the KMZ's produced aren't Garmin Custom Map compatible KMZ files.
    – Gavin
    Jul 16, 2015 at 9:29
  • Do you know why not compatible?
    – Adam Mills
    Aug 6, 2015 at 6:52
  • The structure of the SuperOverlay is different. It has is a kmz with a whole bunch of kmz's within it. The Garmin format is a kmz with a folder of jpg's and a doc.kml file that describes the jpg's extents. No idea why there is alternate structures, but personally I find the Garmin format cleaner... Which is odd as I hate most Garmin data structures.
    – Mike
    Oct 5, 2015 at 6:09
  • @Gavin Did you ever find a solution? I'm running into what I believe is the same problem, see this question.
    – gerrit
    Mar 20, 2016 at 9:54
  • @gerrit Sorry, no. It's on my list of things to look at again soon.
    – Gavin
    Mar 20, 2016 at 22:44
0

If the Geotiff files are each 140 mb in size, the resulting jpg files might still quite big. It might be interesting to split the files into smaller files, so that they can be more easily displayed. You could try with one file using http://www.maptiler.org/ which has an option to generate a KML Superoverlay. MapTiler might not be appropriated to batch process all files, but it is easy to use so that it is good to make some preliminary tests.

If it works as you want, you can then try to batch process all files using GDAL2Tiles. I haven't try it, but I think it should be possible as MapTiler is based on GDAL2Tiles.

3
  • OkMap does this - takes the GeoTIFF and then splits it in to multiple smaller images for use in the KMZ file. gdal2tiles is a handy tool - just haven't figured out how to produce the kmz from it yet. Will play some more.
    – Gavin
    Dec 29, 2011 at 10:28
  • OkMap is new to me. It will have a look at it, it seems to be an interesting program.
    – Name
    Dec 29, 2011 at 12:23
  • gdal2tiles is almost there but OkMap produces much more elegant results. Tile sizes are calculated by OkMap to split the original image efficiently, allowing rectangular tiles rather than square tiles so avoiding extra transparent areas. I wonder if I can somehow automate / command line OkMap to batch process my files.
    – Gavin
    Dec 30, 2011 at 0:36
0

I've never used images in KML, though it looks like gdal2tiles.py may help. Depending on the OS you can do the batch conversion in variety of ways. In Windows with CMD use command: DIR path > yourfile.txt (generate list of your files), import .txt in to Excel/OpenOffice, clean it and add your syntax for GDAL. Save as filename.bat and run it from command line.

4
  • I'm familiar and regularly use gdal2tiles but am a little unsure what settings I should use to spit out kmz. Any ideas?
    – Gavin
    Dec 29, 2011 at 10:18
  • 1
    I guess it's just a case of zipping kml output and images then renaming zip file to kmz extension.
    – Gavin
    Dec 29, 2011 at 10:40
  • That's it. If you want to compress your images, you should have a look what kind of data type it is and maybe change it to something more memory efficient.
    – Tomek
    Dec 29, 2011 at 11:24
  • gdal2tiles is almost there but OkMap produces much more elegant results. Tile sizes are calculated by OkMap to split the original image efficiently, allowing rectangular tiles rather than square tiles so avoiding extra transparent areas. I wonder if I can somehow automate / command line OkMap to batch process my files.
    – Gavin
    Dec 30, 2011 at 0:36
0

Also there is a QGIS plugin to make .kmz files from your QGIS canvas for Garmin devices. It is called GarminCustomMap

0

I posted a python script to use from ArcGIS here:

Exporting 3GB ArcGIS Raster to KML without losing resolution?

The different models support different numbers of tiles. You have to look at this limitation, the extent of imagery you want to use, and the minimum resolution you want to use. Then you need to possibly create multiple files from your original imagery, process each section of imagery with the script tool, and transfer the files from a laptop to the GPS as you need them (Garmin only support 1 "Custom Map" at a time). Many of the *map models only support 100 1024x1024 tiles. The Colorado and Montana support more. I experimented with changing the tile size to 2048 x 2048 and that seemed to still work and allow for quite a bit more data at a time.

In your case I would mosaic to a few multi-Gig images and process these big area's of imagery and let users subset them in google earth and save out their own kmz from there. The Custom Maps thing is intentionally very limiting as Garmin would rather support their jnx format and sell you a Birdseye subscription.... Or force you to hack their devices.

0

OkMap Desktop (full, paid for version) now includes a batch function for generating Garmin Custom Map compatible KMZ files, so I'm now using this.

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.