View License

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

» Watch video

Highlights from
kml contour plot

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.0
4.0 | 2 ratings Rate this file 9 Downloads (last 30 days) File Size: 3.53 KB File ID: #33800 Version: 1.3
image thumbnail

kml contour plot

by

Cameron Sparr (view profile)

 

16 Nov 2011 (Updated )

Create a Google Earth KML file with labelled contour lines.

| Watch this File

File Information
Description

This function can be called exactly the same as one would call MATLAB's CONTOUR function. It directly calls CONTOUR and then takes the output and converts it into a KML file, so that the contour lines display nicely and natively in Google Earth.

NOTE:
If you want to change the color and/or width of the contour lines, you will have to edit lines 38-40 of the function. There are some comments there to guide you.

 Syntax:
     KML_CONTOUR(LON,LAT,Z) writes contour lines in the same format as
     matlab's CONTOUR(LON,LAT,Z) or CONTOURC(LON,LAT,Z).
     KML_CONTOUR(LON,LAT,Z,N) draws N contour lines, overriding the
     automatic value
     KML_CONTOUR(LON,LAT,Z,V) draws LENGTH(V) contour lines at the values
     specified in the vector V
     KML_CONTOUR(LON,LAT,Z,[v v]) computes a single contour at the level v

 Input:
     LON: This can be either a matrix the same size as Z or a vector with
     length the same as the number of columns in Z.
     LAT: This can be either a matrix the same size as Z or a vector with
     length the same as the number of rows in Z.
     Z: Matrix of elevations

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

for anyone interested, I also have a version written in Python available here:
http://www.cameronsparr.com/pytools/

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)
06 Dec 2016 Tom

Tom (view profile)

 
16 Oct 2015 Todd

Todd (view profile)

The software worked very nicely --- thanks Cameron! It would be great if you could specify the lines to have different colors.

Updates
17 Nov 2011 1.1

added link to python version

30 Nov 2011 1.2

Added support for changing the color and width of the contour lines.

15 Dec 2011 1.3

Changed the contour labelling algorithm so that it uses the MATLAB native scheme when given lon,lat,z as a grid, and the proprietary scheme when lon,lat are a list.

Contact us