2

I have a series of KML files (though they could easily be converted to geoJSON, SHP, or anything else that ogr2ogr can handle), each file containing a set of polygons that correspond to the alpha shape (concave hull) of my movements for that day. I'd like to animate the polygons so that I can see how my personal alpha shape changes over time. Is there a particularly straightforward way to do this? I've looked at what Google Earth can offer but I can't help but think there's an easier way.

  • 1
    KML is a natural choice for spatio-temporal presentation as it supports embedded representation of time explicitly associated with spatial features. When you say that you've "looked at what Google Earth can offer," have you looked at the time and animation support in KML? For your current application, the goal would be to merge the multiple, static KML files you currently have into one KML file with multiple TimeStamp-ed Placemarks. – Arthur Sep 26 '13 at 11:57
3

I have done a similar thing using OpenLayers. My use case was actually points not polygons but the principle is the same. I stored the data in a PostGIS back-end and used a simple Python script to update the PostGIS store on a periodic basis (every 10 miliseconds in my case). I then used Geoserver to server the PostGIS layer as a WFS service. If you then use OpenLayers.Strategy.Refresh in your webpage to update your WFS layer, you can achieve nice animation of changing geographic features.

1

This is a quick and dirty example about the animation of polygons using simplekml:

import simplekml
kml = simplekml.Kml()

pol = kml.newpolygon(name='Concave hull 1')
pol.outerboundaryis = [(18.333868,-34.038274), (18.370618,-34.034421),
    (18.350616,-34.051677),(18.333868,-34.038274)]
pol.style.linestyle.color = simplekml.Color.green
pol.style.linestyle.width = 5
pol.style.polystyle.color = simplekml.Color.changealphaint(100, simplekml.Color.green)
pol.timespan.begin = "2013-10-13T08:00:00Z"
pol.timespan.end = "2013-10-13T20:00:00Z"

pol = kml.newpolygon(name='Concave hull 2')
pol.outerboundaryis = [(18.347171,-34.040177), (18.355741,-34.039730),
    (18.350467,-34.048388),(18.347171,-34.040177)]
pol.style.linestyle.color = simplekml.Color.red
pol.style.linestyle.width = 5
pol.style.polystyle.color = simplekml.Color.changealphaint(100, simplekml.Color.red)
pol.timespan.begin = "2013-10-14T08:00:00Z"
pol.timespan.end = "2013-10-14T20:00:00Z"

kml.save("animated_polygons.kml")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.