Visualizing Data with GeoRSS and Virtual Earth

According to the Federal Geographic Data Committee, 80%-90% of all government data has a geographic component. As we offer data to the public, this offers an incredible opportunity to create richer interfaces and allow users to quickly grasp issues that effect them based on location. As RSS becomes more and more prevalent as a way to publish and share information, it becomes increasingly important that location is described in an interoperable manner so that applications can request, aggregate, share and map geographically tagged feeds

GeoRSS is an encoding standard that allows us to add geographical information to any existing RSS or Atom feed. KML is an XML based language that allows us describe geographical information as well. KML seems better suited for strictly visual browsers (as it offers additional data for creating a "camera view"). I’ll focus on GeoRSS since we can easily expose this to users who are currently consuming our feeds.

 

To add GeoRSS data to a feed we need to take two steps

  1. Add the GeoRSS namespace to our feed namespace declarations.
  2. Add a GeoRSS element (point) to our posts.

I’ve created some extension methods to make this easier if you are using the SyndicationFeed class.

public static class SyndicationFeedExtension

{

    private static XmlQualifiedName geoRssXmlQualifiedName = new XmlQualifiedName("georss", "http://www.w3.org/2000/xmlns/");

    private static string geoRssNamespace = "http://www.georss.org/georss";


    public static void AddGeoRSSPoint(this SyndicationItem feedItem, string Latitude, string Longitude)
    {

        feedItem.ElementExtensions.Add(new SyndicationElementExtension("point", geoRssNamespace,Latitude + " " + Longitude));
    }


    public static void AddGeoRSSNamespace(this SyndicationFeed feed)
    {

        feed.AttributeExtensions.Add(geoRssXmlQualifiedName, geoRssNamespace);
    }

}

At this point we have an RSS/Atom feed with location data. What is the best way to display this data? I would use an online mapping service that users are familiar with like Google Maps or Windows Live Maps. Microsoft offers a Virtual Earth Server control as part of its Windows Live Tools. Once we have installed this toolkit, we can drop the control onto a page and tell it to consume the RSS feed we created earlier.

using Microsoft.Live.ServerControls.VE;

public partial class FeedMap : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

    ShapeLayer myPoints= new ShapeLayer();
    ShapeSourceSpecification grants = new ShapeSourceSpecification(DataType.GeoRSS, "MyFeed.aspx", myPoints);
    Map1.ImportShapeLayerData(myPoints, null, true); 
}

}

Leave a Reply

Name *
Email *
Website