rajsingh.org blog

the geoweb, interoperability, OGC, and random rants
July 22nd, 2008

I was at the Earth Science Information Partners (ESIP) meeting last week, and was a little surprised at how much these folks like KML and GeoRSS. OGC stalwarts generally think of simple encodings like these as just good enough to get the job done, if the job you’re doing is pretty simple. The jobs of ESIP members is not, however, simple.

This group is comprised of NASA researchers and other earth, air and water scientists who regularly deal with multi-terabyte databases of satellite imagery and other GIS data sets, so you’d imagine that they would be quite content with their high-end GIS systems. But while there was certainly plenty of industrial strength GIS going on, a good third of the attendees came to the KML and GeoRSS Birds of a Feather session. This made me realize two things:

  1. The work we did in OWS-5 on defining how to output KML from a WFS will be very useful
  2. We’d better tell people about it so they don’t duplicate our efforts

So at this point you’re probably saying, “get to the point. How do you output KML from WFS?” The easy way is to just get software that does it. In OWS-5, the open source Geoserver and Galdos Systems’ commercial product Cartelinea implemented this functionality. If you have your data in PostGIS, ArcSDE, Oracle Spatial, or Shapefiles, just set up the Geoserver or Cartelinea to server that data via the WFS API and you get KML support for output automagically.

If you want to know how to code your own support, you’ll need to read the upcoming revision to the “Styled Layer Descriptor profile of the Web Map Service Implementation Specification”, but I’ll give you the 30-second version here.

A WFS outputs only data (usually in GML format). KML, however, is data plus styling rules. So to control the output of KML from a WFS, you specify the data you want with a normal WFS request, but you also specify the styling rules using the Styled Layer Descriptor (SLD) language. We call this combination of data request API and style configuration a Feature Portrayal Service (FPS). It’s pretty much a melding of the WFS and WMS APIs. So if you’re familiar with WMS, WFS, and SLD, implementing FPS is straightforward. Just read that SLD profile of WMS document and let me know how it goes.

3 Responses to “KML output from a WFS — introducing the Feature Portrayal Service (FPS)”

  1. Of course, if someone has their data in PostGIS or other arbitrary format, they could just render the KML directly without need of using WFS+SLD. The reason I could imagine they’re interested in lighter-weight formats is that they’re easy to deal with and more clients will request them.

    I would also be interested to know the discussions about how they’re using GeoRSS and KML together. GeoRSS as updates to larger KML documents instead of just as another form of the same content.

  2. rajsingh says:

    Andrew, what tools create KML directly from PostGIS, etc.?

    There wasn’t a ton of discussion about using GeoRSS and KML together. The main thing I saw being done in this group with GeoRSS was having Atom+GeoRSS feeds to advertise content, where the GeoRSS part represented the extent of the data set. This was being done completely separate from the output format, so it wasn’t exclusively a KML thing.

  3. Regina says:

    Raj

    PostGIS has a built in function called ST_AsKML which outputs the geometries in KML format record by record. Then you combine these with your attribute data in php or .net or whatever and you are done. I was planning to give an example of this at some point, but haven’t gotten around to it yet.