[mapserver-users] KML thematics from MS Layers

Steve Lime Steve.Lime at dnr.state.mn.us
Wed Jun 4 18:24:39 EDT 2008


MapServer does not have a KML writer that exploits layer styles and such (yet). You do have a couple
of options. One would be to use straight mapscript and your favorite scripting language to build the XML
by hand. Another would be to use query templates...

The key is the [item ...] tag which allows conditional display of text depending on the value of a column. It's
only a single column test at the moment. (Note to self, expose a shapes class via templates...) So, you 
could something like:

  [item name="foo" pattern="1" format="#FFFFFF"][item name="foo" pattern="2" format="#FF0000"]

and then depending on the value of item foo you'd get either a while hex color string or a red hex color string.
Put that in a template that generates KML and you could change appearance on a feature by feature basis. The
development version (the upcoming 5.2) makes this easier by simplifying template generation. See RFC 36
(http://mapserver.gis.umn.edu/development/rfc/ms-rfc-36/) for details. There's an example there for GML that
could be extended to generate KML.

Then, to generate the KML you'd simply use on of the query modes for the MapServer CGI so you could limit the
result set anyway you'd want. Of course you have to know a bit of KML to use this approach.

An idea anyway...

Steve

>>> On 6/2/2008 at 7:09 AM, in message
<89f54d350806020509o7cdfc251i1a2e35aeb87fa29f at mail.gmail.com>, "Sarel Coetzer"
<geotech.sarel at gmail.com> wrote:
> Hi
> 
> Need some advice on how to create thematic looking KML layers from MapServer
> layers that is classified in 5 thematic classes.
> This is a long shot and might be the wrong forum but I haven't had success
> in the GDAL or OGR forums
> 
> Sarel
> 
> 
> 
> 
> 
> -- 
> "http://sarelgis.blogspot.com/"



More information about the mapserver-users mailing list