KML Regions
Purpose/Goal/Introduction
We want to display our Gulf of Mexico velocity vector (and perhaps other) fields via Google Earth. This requires that we use KML - the language of Google Earth - to encode the needed information. The basic steps are:
Creating the Images
A good place to start is with the OCTANT package available at:
http://code.google.com/p/octant/
wherein an experimental bit of Python code called googleearth.py can be found at:
http://code.google.com/p/octant/source/browse/trunk/octant/sandbox/googleearth.py
Matplotlib
The matplotlib plotting package is found at:
http://matplotlib.sourceforge.net/
and the basemap toolkit at:
http://matplotlib.sourceforge.net/basemap/doc/html/
Quiver
Examples of the use of quiver can be found at:
http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html?highlight=quiver
with the example source codes at:
http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/quiver_demo.py
Example Program
#!/usr/bin/env python
# encoding: utf-8
"""
vecplot.py
"""
import matplotlib
matplotlib.use('Agg')
from numpy import *
from pylab import *
from matplotlib.pyplot import *
import pylab
import zipfile
import octant
import os
infile = '/raid/Data/NARR-UV-txla_grd-200001.nc'
nc = octant.io.Dataset(infile)
lat = nc.variables['lat_rho'][:]
lon = nc.variables['lon_rho'][:]
# Snag just the first time step in each file.
u = nc.variables['Uwind'][0,:,:]
v = nc.variables['Vwind'][0,:,:]
q = quiver(lon,lat,u,v)
:wq
KML Regions
The best introduction to KML Regions can be found at the KML 2.1. Tutorial at:
http://code.google.com/apis/kml/documentation/kml_21tutorial.html
The official propaganda tells us that:
Regions are a powerful new KML feature that allows you to add very large datasets to Google Earth without sacrificing performance. Data is loaded and drawn only when it falls within the user's view and occupies a certain portion of the screen. Using Regions, you can supply separate levels of detail for the data, so that fine details are loaded only when the data fills a portion of the screen that is large enough for the details to be visible.