Mapping GeoRSS Feeds and the Shift from KML to GeoJSON Michael P. Peterson

ABSTRACT: A primary benefit of cloud-based mapping is the presentation of updated maps. Data can be made available through a based on RSS - Really Simple Syndication. The data format for geographic data that was initially widely adopted for RSS feeds was KML and its compressed variant, KMZ. Increasingly, these feeds are being provided in the more flexible GeoJSON format. The JSON was specifically designed for JavaScript, now the most- used . Investigated here is the RSS landscape for updated map data, the shift to GeoJSON and the public display of updated maps.

KEYWORDS: RSS, GeoRSS, Data syndication, XML, KML, GeoJSON, Public display of maps

Introduction In cases where data is frequently updated, a web format called Really Simple Syndication (RSS) is often used. With origins to the late 1990s and a browser called , RSS used the eXtensible (XML) format to distribute news, stories, and other updated information (Hammersly 1999, p. 3). Subscribing to a RSS would remove the need for the user to manually check the website for new content. Instead, the browser would constantly monitor the site. After Netscape dropped development, the format went through a variety of hands and new ‘standard’ formats were created. In some circles, RSS came to stand for Rich Site Summary.

An RSS feed is composed of content and . The metadata describes the data and includes such attributes as date and author. A standardized file format allows the information to be published once and viewed using many different programs. Publishers of RSS feeds benefit by syndicating content automatically while consumers benefit through timely updates from favored . RSS is an efficient form of data distribution for both publisher and user.

GeoRSS is a variant that encodes geographic location (Chow 2011, p. 21). While a GeoRSS standard was proposed based on the Geographic Markup Language (GML) and a simpler format called , many current geographic feeds use the KML format (OGC 2006). Developed for Google Earth, KML is an open standard officially called the OpenGIS® KML Encoding Standard (OGC KML) and is maintained by the Open Geospatial Consortium (OGC). The format specifies features such as placemarks, images, polygons, and 3D models.

The JSON (JavaScript Object Notation) file format is increasingly being used for RSS- type feeds. Based on JavaScript, now the most commonly-used programming language in

141 the world. Introduced in 1995 to make web pages more interactive, the programming language did not originally facilitate the reading of files out of security concerns. A method of file input was introduced that parsed XML files but this proved to be very slow. Originally introduced in 1999, JavaScript Object Notation (JSON) developed over the past decade as a fast method of data input. The file format represents simple data structures called objects. The files can be read quickly and is completely language independent. JSON is an ideal interchange format between languages as it can be used to read data in a variety of formats including number, string, value, array, and object. By eliminating the need for a separate parsing function, JSON improves security and speed of .

GeoJSON is a particular variation of JSON for geographic data. It has been specifically designed for encoding of geographic data structures. Spatial data types supported by GeoJSON are points, polygons, multipolygons, features, geometry collections, bounding boxes, and their associated attributes.

There are a number of data feeds available from different governmental organizations in both the KML and GeoJSON formats. A variety of these feeds are examined and mapped using the Google Maps Application Programmer Interface (API), the most commonly- used API for mapping. We first examine how the API displays the KML and GeoJSON file. Then, an inventory of feeds is undertaken, primarily those available through the National Oceanic and Atmospheric Agency (NOAA) and the United States Geological Survey (USGS). A variety of these feeds are mapped for public display (Peterson 2005) using the Google Maps API. Mapping Data Feeds A variety of Application Programmer Interfaces (API) can display GeoRSS feeds. In mapping with the Google Maps API, the google.maps.KmlLayer function reads a KML- formatted RSS feed specified with a standard http address, more formally referred to as Uniform Resource Location (URL). This means that the KML file must be hosted by a server. A disadvantage of displaying files through the KmlLayer function is that there is little control over the look of the actual map as symbolization is normally defined within the KML file.

Flickr.com offers a way to form a feed of pictures that have recently been uploaded for a specific place. The following GeoRSS URL shows recently uploaded photos for San Francisco:

https://www.flickr.com/services/feeds/geo/United+States/Californi a/San+Francisco?format=rss_200

This file can be displayed through the Google Maps API with the JavaScript function shown in Figure 1.

142 function initialize() { // Center and zoom level are re-defined later based on points in feed var myLatlng = new google.maps.LatLng(49.496675,-102.65625); var myOptions = { zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } // Create the map object var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

// Change the line below to another state and city var georssLayer = new google.maps.KmlLayer('https://www.flickr.com/services/ feeds/geo/United+States/California/San+Francisco?format=rss_200'); georssLayer.setMap(map); }

Figure 1. Displaying a KML feed from Flickr with the Google Maps API. Clicking on an icon displays the image and associated metadata. Example from Peterson (2014).

Based on XML, KML files can be very large. To reduce the file size, a KMZ file was defined that is a zipped (compressed) version of the KML file. The file can be expanded with any type of unzipping program. For display purposes with the Google Maps API, unzipping is not necessary because the google.maps.KmlLayer option unzips the file automatically.

To further increase the speed of display, Google implemented the caching of KML files at the server level. While the caching of files is common with browsers and can be easily undone by clearing the cache, there is no way for a normal user to clear the cache on a server. In addition, the KML file is cached by the server for an unknown period of time – usually a day or two. Referencing the file through its web address on subsequent calls will display the cached version. This means that changing the contents of the file will not change the file that is displayed by the Google Maps API. The older version of the file will be shown until the cached file is released. This complicates the use of KML for updated data feeds.

143 A work-around is to add a random number to the secondary part of the file name. This number tricks the Google server into displaying the updated file, and caching another version of this file. The code for this random number file naming method is shown in Figure 2.

var kmlURL = "http://maps.unomaha.edu/cloud/code/code12_with_data/ three_points+icon.kml" + "?" + Math.round(Math.random() * 10000000000); var georssLayer = new google.maps.KmlLayer(kmlURL);

Figure 2. KML files are cached at the server level. This code circumvents the cached version by assigning a random number to the address of the file.

GeoJSON files are handled similarly by mapping APIs. The code for displaying a GeoJSON with the Google is shown in Figure 3. The loadGeoJson option was not available in the Google Maps API until 2014 (Directions 2014). Many suspect that Google saw GeoJSON as a competition to KML and delayed incorporating the integration of this format.

function initialize() { // Create a simple map. map = new google.maps.Map(document.getElementById('map-canvas'), { zoom: 2, center: {lat: 42.892434, lng: -36.250050}, });

// Load a GeoJSON file map.data.loadGeoJson('geoJSON_line.');

// Overlay Styles map.data.setStyle({ strokeColor: '#2687bf', strokeWeight: 6 }); }

144 Figure 3. A JavaScript function that displays a GeoJSON file. After the file is loaded, a stroke color and weight is defined. Example from Mapping in the Cloud (2014).

The major advantage of GeoJSON can be seen in Figure 3 in the code that follows the loading of the file. Here, a style is attached to the line before it is displayed (thicker bluish line). This type of styling is much more difficult with KML. Another advantage of GeoJSON is that it does not need to be referenced through an URL. But, like KML, the files also seem to be cached on an intermediate server. Available GeoRSS Data Feeds in KML There are a number of data feeds available from different governmental organizations. The National Oceanic and Atmospheric Association (NOAA) has the largest number and variety of feeds. Their GeoRSS feeds are mostly provided through a site titled “National Weather Data in KML/KMZ formats.” Figure 4 shows eight different feeds from NOAA mapped with the Google Maps API. Updated versions of these maps are available through the Geographic Data Feed Landscape website (http://maps.unomaha.edu/GeographicDataFeedLandscape/).

145

Figure 4. A variety of KML data feeds available through NOAA’s National Weather Data in KML/KMZ site rendered with Google Maps API on June 7, 2016. All except the Great Lakes water temperature map are vector overlays. The Great Lakes KML makes reference to a GIF file, a raster format.

The colors and symbols used in the map are embedded within the KML file, and few of the feeds include any type of legend. Changing the symbols or colors or adding a legend would require a conversion of the KML file. In other words, the file would need to be downloaded, edited, and uploaded again to a webhosting site. After this conversion and uploading, the revised KML file could be referenced and displayed.

NOAA started distributing KML feeds around 2010. Many of the feeds available through the National Weather Data in KML/KMZ site are no longer being updated. Of the 58 links on NOAA’s KML site, only about half are still active. Of these, only about 15 display any kind of meaningful map.

Private companies have begun to provide some of the same data and maps as NOAA. Openweather.org provides access to a weather database charges up to $3,000 a month for access. They provide data feeds in both KML and GeoJSON. Wunderground.com, now owned by The Weather Channel, offers a similar paid service. NOAA recognizes the problem of interfering with the private sector by stating:

NWS supports private sector efforts to develop complementary services (e.g., products, communication services, information capabilities) that offer users access to the most complete hydrometeorological information possible. (NOAA Dissemination Services 2016)

146 It would seem that the continued distribution of free NOAA weather data feeds will be hampered by business interests and their ability to profit from the distribution of weather data and maps. Available GeoRSS Data Feeds in GeoJSON There are still many more geographic data feeds in KML than GeoJSON. As previously mentioned, the Google Maps API did not support the format until 2014. The best-known GeoJSON feed is of earthquakes and is provided by the Earthquake Hazards Program at USGS (see Figure 5). The site provides links to earthquakes of different magnitudes over the past hour, day, week, and month. These GeoJSON files are updated continuously throughout the day.

Figure 5. GeoJSON feeds available through USGS’s Earthquake Hazards Program website at http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php.

Figure 6 shows a single earthquake event in a GeoJSON format from the USGS. This comes from the Magnitude 4.5+ Past Day feed for June 8, 2016. The event describes an earthquake of magnitude of 5.2 in the Southern Mid-Atlantic Ridge with the latitude and longitude and other relevant information. The record also includes the tsunami potential of 0. Figure 7 depicts four maps produced from USGS GeoJSON feed of earthquake data on June 8, 2016.

147

Figure 6. One earthquake event from the USGS GeoJSON feed. The earthquake occurred in the Southern Mid-Atlantic Ridge and had a magnitude of 5.2.

http://maps.unomaha.edu/Peterson/Display/Earthquakes/1_Hour. http://maps.unomaha.edu/Peterson/Display/Earthquakes/2_Day.html

http://maps.unomaha.edu/Peterson/Display/Earthquakes/3_Week.html http://maps.unomaha.edu/Peterson/Display/Earthquakes/4_Month.html

Figure 7: Maps of earthquakes for the past hour, day, week and month for June 8, 2016. The area known as the ring of fire becomes clearly visible through the four maps. Sensors in the US are more sensitive than in other parts of the world and this is clearly apparent in the 24-hour map with the many smaller circles.

Mapping GeoRSS feeds for Public Display The Department of Geography at the University of Nebraska at Omaha has been displaying updated weather maps in a prominent display case since 1999. A series of six computers automatically download and display updated maps at regular intervals (see

148 Figure 8). The Macintosh computers are set to run automatically, starting up at 7 AM and shutting down at 10 PM.

Figure 8: Updated public map display operated by the Department of Geography / Geology at the University of Nebraska at Omaha. The earthquake display at right depicts updated earthquake maps.

An earthquake map display was added using an extension to the Chrome browser. The extension, Revolver, cycles between a series of open tabs. The four tabs correspond to the four maps shown in Figure 7. On startup, the computer opens Chrome and Revolver and then cycles between the four maps, displaying each map for ten seconds. A number of observations were made in creating the public display of earthquake maps. For example, in scaling of circles in the earthquake display, it was observed that the particular scaling factor needed to be different between the hourly, daily, weekly and monthly maps. This is because the range of earthquake magnitudes is smaller in the shorter time periods. To compensate, the scaling factor becomes smaller as the maps progress through the four time periods.

Summary RSS is a method for delivering updated data at regular intervals. It can be extremely valuable for frequently updated types of geographic information but could be used for

149 any type of geographic data – even data that is not frequently updated. The file format that has been traditionally associated with GeoRSS is KML. An alternative format, GeoJSON, has begun to slowly replace this format. The advantages of GeoJSON are speed and flexibility in the display of the map. For example, the map.data.setStyle option in the Google Maps API allows for symbolization. A similar technique is not possible with KML.

A number of geographic feeds have been examined and mapped with the Google Maps API. Most of these display different types of weather-related data from NOAA. Many of these data feeds are no longer current. Private sector interests may be hampering further development of NOAA weather feeds. It is important that geographic data feeds remain open and free.

The public display of maps involves downloading a KML or geoJSON. In many cases, the data need to be symbolized. Very little work has involved the symbolization of KML or GeoJSON feeds. Properly displayed in a private or public setting, the maps provide important insights into a dynamic world.

References Chow, Edwin T. (2011) Geography 2.0 – A Mashup Perspective. In Advances in Web- based GIS, Mapping Services and Applications ed. by Songnian Li, Suzana Dragicevic, Bert Veenendaal. ISPRS Book Series. Boca Raton, FL: CRC Press, pp. 15-36. Directions Magazine (2014) Google Announces JavaScript Maps API Support for GeoJSON. March 19th, 2014. [http://www.directionsmag.com/entry/google- announces-javascript-maps-api-support-for-geojson/390217] Hammersly, Ben (2003) Content Syndication with RSS. Sebastopol, CA: O’Reilly Associates. NOAA Dissemination Services (2016) National Weather Service Office of Climate, Water and Weather Services [http://www.nws.noaa.gov/os/disemsys.shtml} OGC-Open Geospatial Consortium (2006) An Introduction to GeoRSS: A Standards Based Approach for Geo-enabling RSS feeds. OGC Whitepaper (pdf)

Peterson, Michael P. (2014) Mapping in the Cloud. Guilford: New York, NY.

Peterson, Michael P. (2005) Pervasive and Public Map Displays. In Taylor, F. (ed.) Cybercartography. Amsterdam, Cambridge: Elsevier Press.

Michael P. Peterson, Professor, Department of Geography / Geology, University of Nebraska - Omaha, Omaha, NE 68182.

150