Step 1: Get a basemap image: http://tools.pacificclimate.org/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=osm_pnwa_green_brown&styles=&bbox=-236114,43873.25,2204236,1772084.75&width=1024&height=768&srs=EPSG:3005&format=image/png

Step 2: Script the WMS requests for stations

filter_template = '''<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:And><ogc:And><ogc:PropertyIsGreaterThanOrEqualTo>\
<ogc:PropertyName>max_obs_time</ogc:PropertyName><ogc:Literal>{start_date}</ogc:Literal>\
</ogc:PropertyIsGreaterThanOrEqualTo><ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyName>min_obs_time</ogc:PropertyName>\
<ogc:Literal>{end_date}</ogc:Literal></ogc:PropertyIsLessThanOrEqualTo></ogc:And></ogc:And></ogc:Filter>'''

def make_filter(decade):
    start_year = 1880
    end_year = 1889
    y0 = start_year + decade * 10
    y1 = end_year + decade * 10
    start_date = '/'.join(map(str, [start_year, '01', '01']))
    end_date = '/'.join(map(str, [end_year, 12, 31]))
    return filter_template.format(**locals())

Loop over the decades making requests to here: http://tools.pacificclimate.org/geoserver/CRMP/wms?service=WMS with some additional parameters:

params = {'version': '1.1.0',
          'request': 'GetMap',
          'layers': 'CRMP:crmp_network_geoserver',
          'bbox': "-236114,43873.25,2204236,1772084.75",
          'width': 1024,
          'height': 768,
          'srs': 'EPSG:3005',
          'format': 'image/png'
          }

Step 3: Use imagemagick to add transparency to all of the station images.

for i in map[0-9].png map[0-9][0-9].png; do convert $i -transparent white alpha_$i; done

Step 4: Do the compositing with imagemagick.

for i in alpha_map?.png alpha_map??.png; do f=`echo $i | sed -e s/alpha_map// -e s/.png//`; composite $i basemap.png full_map$f.png; done

Step 5: Animate with imagemagick.

convert -loop 1 -delay 20 full_map?.png full_map??.png animation.gif



blog comments powered by Disqus

Published

21 August 2013

Category

work

Tags