For part 2 of the Weather Underground API post, I’ll be taking weather data, and injecting it into a KML file. The Keyhole Markup Language (KML) is an XML based format that allows geographic data e.g. lines, points, polygons, to be easily seen in compatible viewers.
Using the previous post as a starting point, we’ll be adding:
- Front Matter. Starts the KML file, defines the encoding, has a concise description of the file.
- Style Section. Defines the way the balloons and text will look in the KML file.
- KML Encoding. The information from the Wunderground API call is encapsulated in pertinent KML.
- System.IO.File. Is used to write the output file.
As can be seen in the above image, the KML file is created, and the front matter/style is written. Afterwards a modified ‘parse’ method makes the API call and generates a KML waypoint that the user can click for the weather information.
The generated KML can be viewed in any compatible GIS program, typically Google Earth.
Full project file for Visual Studio can be found here: Wunderground_API_Test