View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Google Earth Overlay

4.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 11.5 KB File ID: #33699 Version: 1.1
image thumbnail

Google Earth Overlay


Cameron Sparr (view profile)


09 Nov 2011 (Updated )

Overlay a MATLAB figure, .fig file, or image file onto Google Earth.

| Watch this File

File Information


     export_overlay(filename, output, [N, S, E, W])
     export_overlay(filename, output, [N, S, E, W, R])

     filename: must be either:
                 1. Google Earth supported image file (see below), OR
                 2. MATLAB format .fig file, OR
                 3. a figure object handle (use gcf for current figure)

     output: .kmz file name (string, relative or full path)

     rect: 4 or 5-element vector in the following format:
             [north boundary, south bound, east bound, west bound, rotation]

     NOTE: If you specify a figure handle or .fig file, it will be exported
           as a TRANSPARENT .png file.

           .bmp, .dds, .gif, .jpg, .pgm, .png, .ppm, .tga, .tiff, .tif

     % this will place an overlay of a random plot over Hawaii.
     plot(1:1:10, rand(10,1), 'w');
     rect = [21.37, 21.36, -157.971, -157.973];
     export_overlay(gcf, 'output.kmz', rect);

     % this will overlay a PNG image over the same location.
     % (Assuming 'contour.png' is defined)
     rect = [21.37, 21.36, -157.971, -157.973];
     export_overlay('contour.png', 'contour.kmz', rect);

     % you may also use full or relative paths to various images you would
     % like to overlay.
     rect = [21.37, 21.36, -157.971, -157.973];
     file1 = '/home/user/Desktop/contour.png';
     file2 = 'figfiles/myfig.fig';
     export_overlay(file1, 'contour.kmz', rect);
     export_overlay(file2, 'myfig.kmz', rect);


Export Fig inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
17 Jun 2015 Lyn Harris

Here's the original line 414 that Matlab had an issue with:
imwrite(A, [ '.png'], 'Alpha', alpha, 'ResolutionUnit', 'meter', 'XResolution', res, 'YResolution', res);
Here's the fix:
imwrite(A, [ '.png'], 'Alpha', double(alpha), 'ResolutionUnit', 'meter', 'XResolution', res, 'YResolution', res);

Comment only
20 Jun 2014 Lyn Harris

Works great; my data line up just right on Google Earth. I had to make one minor change in export_fig as imwrite apparently wants alpha to be double and it was single (using R2013b).

17 Nov 2011 1.1

With the help of Oliver Woodford, I simplified the functions required and incorporated the export_fig functions into one file. Also fixed a transparency compatibility issue with the newest MATLAB release.

Contact us