Karten
Code
Importing
# -*- coding: iso-8859-1 -*-
import sys
import numpy as N
#import shapefile
import scipy.stats as stats
import pylab as P
from matplotlib.collections import PatchCollection
from pylab import Polygon
from mpl_toolkits.basemap import Basemap
import shapefile
from osgeo import ogr
#P.style.use('bmh')
params = {'legend.fontsize': 8,'font.family': 'serif'}
P.rcParams.update(params)
Plotting
fig = P.figure(figsize=(12,4))
ax = fig.add_subplot(111)
m = Basemap(projection='merc',llcrnrlat=47,urcrnrlat=55.2,llcrnrlon=5,urcrnrlon=16,resolution='l')
m.readshapefile('../data/shp/deu', 'pds',zorder=10)
patches = []
for info, shape in zip(m.pds_info, m.pds):
patches.append( Polygon(N.array(shape), True, color='None') )
pc = PatchCollection(patches, match_original=True, edgecolor='k', linewidths=0.1, zorder=2)#, alpha=0.5)
ax.add_collection(pc)
m.readshapefile('../data/shp/opt', 'pds',zorder=10)
patches = []
for info, shape in zip(m.pds_info, m.pds):
patches.append( Polygon(N.array(shape), True, color='r') )
pc = PatchCollection(patches, match_original=True, edgecolor='r', linewidths=0.1, zorder=2)#, alpha=0.5)
ax.add_collection(pc)
dat = N.genfromtxt('../data/csv/stations.tab',names=True,dtype=None)
no = len(dat['lon'])
for o in range(no):
x,y = m(dat['lon'],dat['lat'])
P.scatter(x,y,c='k',s=1,lw=0.0,zorder=30)
P.axis('off')
fig.tight_layout()
fig.savefig('./img/karten.png',dpi=240,transparent=False,bbox_inches='tight',pad_inches=0.0)