kml line plot

Draw nan-separated lines (or a single line) onto Google Earth.
995 Downloads
Updated 13 Apr 2012

View License

This function takes in standard nan-separated arrays (such as for a coastline), and draws them onto Google Earth.

It can also handle a single lon/lat track that has no NaN values (such as a ship or airplane track).

Syntax:
KML_LINE(LON, LAT) writes nan-separated lines specified
in LON and LAT to an output file, doc.kml
KML_LINE(LON, LAT, NAME) writes nan-separated lines specified
in LON and LAT to an output file, NAME.kml
KML_LINE(LON, LAT, NAME, COLOR) writes lines same as above but with
MATLAB color value (default is 'w').
KML_LINE(LON, LAT, NAME, WIDTH) writes lines same as above but with
width WIDTH (default is 1).
KML_LINE(LON, LAT, NAME, COLOR, WIDTH) writes lines same as above but
with width WIDTH and color COLOR.

Input:
LON: 1-D array of longitude line values. Separate lines are separated
by a NaN. Must correspond to LAT.
LAT: 1-D array of latitude line values. Separate lines are separated
by a NaN. Must correspond to LON.
NAME: String name of output file (without the .kml extension)
COLOR: MATLAB color (default is 'w'), supports vector colors.
WIDTH: int or float width value (default is 1)

Output:
This function creates a kml file called NAME.kml in the current
working directory

Examples:
% four different ways of calling kml_line:
load('palau_coastline.mat');
kml_line(lon_coast, lat_coast, 'palau_coastline');
kml_line(lon_coast, lat_coast, 'palau_coastline', 'r');
kml_line(lon_coast, lat_coast, 'palau_coastline', 1.5);
kml_line(lon_coast, lat_coast, 'palau_coastline', 'm', 2);

Cite As

Cameron Sparr (2024). kml line plot (https://www.mathworks.com/matlabcentral/fileexchange/34006-kml-line-plot), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.6.0.0

Now prints out 10 digits of accuracy as opposed to 4.

1.5.0.0

Now uses ge_color function so that the color input can be in standard MATLAB form.

1.4.0.0

Major revision on how it handles line styles (now makes use of styleUrl). Also added support for writing a KML without specifying a name.

1.3.0.0

Updated file to support changes in the color and/or width of the lines

1.1.0.0

updated description to include support for single lines

1.0.0.0