# python code to generate kml snapshots of a spreading plume
import random
import math
centlon = -157.942858
centlat = 21.333217
ident = 1
day = 12
month = 12
year = 2012
minute = 0
starthour = 0
endhour = 24
spreadrate = 5.0 * 0.01666 # decimal degrees / hr
windxrate = 15.0 * 0.01666 * -1.0
windyrate = 5.0 * 0.01666 * -1.0
# print kml header stuff...
print ""
print ""
for hour in range(starthour, endhour):
# update center
centlon += windxrate * random.random()
centlat += windyrate * random.random()
# print kml to start one placemark
# using the name field to associate a time as: dd/mm/yyyy hh:mm
# and inidicating that we have a polygon with coordinates listed
print " "
print " %02d/%02d/%4d %02d:%02d" % (day, month, year, hour, minute)
print " "
print " "
# adjust the radius and loop around the compass computing points
# and printing them (not sure that the explicit closure by repeating
# the first point is required)
radius = hour * spreadrate
for radial in range (0, 360, 10):
radi = radius + ((random.random() * 0.2) - 0.1)
lon = centlon + radi * math.cos(math.radians(radial))
lat = centlat + radi * math.sin(math.radians(radial))
if radial==0:
flon = lon
flat = lat
print " %lf,%lf,0" % (lon, lat)
print " %lf,%lf,0" % (flon, flat)
# finish each coordinate list, Polygon and Placemark
print " "
print " "
print " "
# finish the kml
print ""