This script (contributed by Robert Branton) shows how to make a map showing the station locations of the Ocean Tracking Network (OTN).
# -*- coding: utf-8 -*- """ Created on Sat Feb 16 19:29:10 2013 @author: bob.branton@dal.ca Purpose: draw simple map of Ocean Tracking Network (OTN) station locations 1) Create function to get station locations from genric node 2) Run function to get data from otn and post nodes 3) Draw empty basemap of the world 4) Overlay station locations on basemap For more on OTN: http://members.oceantrack.org/data """ import numpy as np import urllib2 import StringIO import csv from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt #define data variable lats, lons = [],[] # 1) Create function to get data from otn a network node def getdata(node): response = urllib2.urlopen('http://global.oceantrack.org:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&outputFormat=CSV&typename='+node+':stations') data = response.read() data = StringIO.StringIO(data) r = csv.DictReader(data, dialect=csv.Sniffer().sniff(data.read(10000))) data.seek(0) for row in r: lats.append(float(row['latitude'])) lons.append(float(row['longitude'])) # 2) Run fuction to get date from each otn node, that is otn and post getdata('otn') getdata('post') # 3) Draw gloabal basemap # map = Basemap(projection='ortho', lat_0=50, lon_0=-100, resolution='l', area_thresh=1000.0) map = Basemap(projection='robin', lat_0=0, lon_0=-100, resolution='l', area_thresh=1000.0) map.drawcoastlines() map.drawcountries() map.fillcontinents(color='coral',lake_color='aqua') map.drawmapboundary(fill_color='aqua') map.drawmeridians(np.arange(0, 360, 30)) map.drawparallels(np.arange(-90, 90, 30)) plt.title("Ocean Tracking Network Stations") # 4) Overlay station locations on basemap x,y = map(lons, lats) map.plot(x, y, 'wo',markersize=8) plt.show() # done
This code requires the installation of matplotlib’s basemap toolkit. Available at: http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/
This in turn requires installation of GEOS and PROJ4, two libraries that need to be built from source.
It’s worth doing, but for the beginning user it may be a bit daunting. For a Mac user, it requires [ MacPorts | Fink | Homebrew ] or a familiarity with building from source on the Mac platform.