Geoserver KML output

As mentioned a while back, Geoserver had some experimental code for KML output. The latest PR1 release has vastly improved KML support, largely submitted by James MacGill.

There was a recent question on the GS-Users list about how to use the sucker inside Google Earth. My personal preference is still for WMS overlays, but if for some reason you’d like your live data outputted as KML, read on.

1. First things first, grab the PR1 release.

2. Setup your desired datastore using the GS web interface. In my case i will configure a new ArcSDE datastore.

3. Add your new featuretype, making sure you set the SRS as 4326 and generate the corresponding bounding box.

Featuretype config

4. Do the old Apply/Save/Load trick to load your changes.

5. Now our data is ready to go, we better check KML output is supported. Send a WMS (yes, WMS) GetCapabilities to your service and check that you have the following,


6. We’re almost done. Now all we need to do is setup a corresponding network link to point to the “KML document” (which is in fact, just a WMS call to the KML output format).

Add the following in the location box for a new network link,


and set the refresh parameters to fly-based refresh after “4 secs”

Refresh params

7. Assuming all went ok, you should now have a feature for each polygon which can be toggled individually.


If you are feeling lucky, try adding label definitions and view scales to your SLD. Otherwise you may be unintentially trying to retrieve a KML file containing your whole road dataset :)

Be aware that due to the way GS extracts each feature, the polygon extents can and will extend beyond the requested BBOX, which can be a good or a bad thing i guess.

Things that could well be added in the future: KMZ support, more customisable KML output (such as Z/height attributes) … the list goes on. The flexibility in using the available Geoserver datastores certainly makes this a viable alternative to using the 100 different “arc exporters”. You just can’t beat live data getting sucked straight from your database

If this article interests you, please swing by the GS-Users list and say gday, they are always keen to get more contributors on board.

8 thoughts on “Geoserver KML output”

  1. Hi, sounds great…but why SRS always 4326???. My dates are all in EPSG:23030 (UTM ED-50), geoserver can’t reproject it?. I can’t change my coordinate system!!!

  2. Fernando, WGS84 (4326) is required because thats the datum Google Earth uses!

    Search the geotools/geoserver wiki as i’m sure theres an article highlighting how you can add new projection systems such as your UTM ED50

  3. Hi,

    I can’t get this to work!

    Here is the xml sent back from the geoServer (1.3.3):

    null is not a valid pair of coordinates

    Where do i put the coordinates?

    any help appreciated,


  4. Alex, what url are you trying to connect to using Google Earth. Geoserver now has an inbuilt reflector so it should be a lot simpler than discussed in this article!

  5. Hi Chris,

    I got it working by adding the bbox to the end of the URL (ahem… after reading the documentation Earth )

    The full URL that I am using (but experiencing draw flickering with is http://localhost:8080/geoserver//wms?service=WMS&request=GetMap&format=application/ XML&width=1024&height=1024&srs=EPSG:4326&layers=mfdb:ENC_Land_Area&styles=line&bbox=-130,45,-125,90

    Is there a better way of doing this?

    Good blog by the way,


  6. Hi Chris
    I’d do all the stuff, but when I tried to open in Google Earth the following message apppears on Geoserver window:

    29 ago 09:57:57 INFO [wms.servlets] – KML NetworkLink sharing 1 layer(s) created.
    29 ago 09:58:30 ERROR [geoserver.ows] –
    org.vfny.geoserver.wms.WmsException: There is no support for creating maps in application/ XML format

    It’s there a special version of geoserver? I have \GeoServer 1.7.0-RC1

  7. Great blog – Carlos, I’ve been battling the same issue. It’s a bug in Geoserver 1.7.0-RC1 – I installed the latest stable release 1.6.4 and now it’s working fine.

Comments are closed.