-
Notifications
You must be signed in to change notification settings - Fork 2
/
MapUtils.py
28 lines (22 loc) · 1.22 KB
/
MapUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os.path # for os.path.dirname(), os.path.abspath(), os.path.sep
# Default Map display options
mapLayers = [['states', {'linewidth':1.5, 'color':'k', 'zorder':0}],
['counties', {'linewidth':0.5, 'color':'k', 'zorder':0}],
['roads', {'linewidth':0.75, 'color':'r', 'zorder':0}],
['rivers', {'linewidth':0.5, 'color':'b', 'zorder':0}]]
def PlotMapLayers(map, layerOptions, axis=None):
for layer in layerOptions :
if layer[0] == 'states' :
map.drawstates(ax=axis, **layer[1])
elif layer[0] == 'counties' :
map.readshapefile(os.path.sep.join([os.path.dirname(os.path.abspath(__file__)), 'shapefiles', 'countyp020']),
name='counties', ax=axis, **layer[1])
elif layer[0] == 'rivers' :
map.drawrivers(ax=axis, **layer[1])
elif layer[0] == 'roads' :
map.readshapefile(os.sep.join([os.path.dirname(os.path.abspath(__file__)), 'shapefiles', 'road_l']),
name='road', ax=axis, **layer[1])
elif layer[0] == 'countries':
map.drawcountries(ax=axis, **layer[1])
else :
raise TypeError('Unknown map_layer type: ' + layer[0])