reposted from
KML2STRUCT – Easily Import Your KML Files
Posted by Sean de Wolski,
Import Your KML Files
Earlier this week, my friend sent me a Google Maps link containing our hiking tracks recorded with the GPS on his smart phone. From Google Maps you can download the data as a KML (Keyhole Markup Language) file.

I wanted to plot it and experiment with the data in MATLAB. Once again, the File Exchange was there for me!
Now looking at the table, we can see the four important pieces:
- Geometry: What is it? A point, line, etc.
- Lon: Longitude coordinate of tracks
- Lat: Latitude coordinate of tracks
- Bounding Box: Bounding box if we want to draw it on a map
First, I'll get the bounding box of the whole trip. To do this, we'll stack each segment's bounding box into the third dimension and then pick the min and the max:
Next, I only want to work with the lines, i.e. the actual tracks. The points represent termini, which I don't need right now. Using the new categorical data type and logical indexing, we can extract the latitude and longitude from the table.
I'll get the elevation data from NASA using the Web Map Service in the Mapping Toolbox.
And finally, plot a contour map with the tracks overlaid on it.

Comments
Have you ever recorded a trip and then tried to analyze it in MATLAB? The tasks above would be more straight-forward if you had access to the original GPX files. These typically come with the elevation data and time stamps allowing you to get even more statistics with more accuracy.
No comments:
Post a Comment