-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot_coastline_overimage.py
More file actions
78 lines (54 loc) · 2.28 KB
/
plot_coastline_overimage.py
File metadata and controls
78 lines (54 loc) · 2.28 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from __future__ import division,print_function
import matplotlib as mpl
import scipy as sp
from datatools import *
from gridtools import *
from plottools import *
import interptools as ipt
import matplotlib.tri as mplt
import matplotlib.pyplot as plt
#from mpl_toolkits.basemap import Basemap
import os as os
import sys
np.set_printoptions(precision=8,suppress=True,threshold=sys.maxsize)
import time
from matplotlib.collections import LineCollection as LC
from matplotlib.collections import PolyCollection as PC
import matplotlib.path as path
# Define names and types of data
imgfile='figures/png/misc/vh_harbour_google_nogrid.jpg'
savepath='figures/png/misc/'
if not os.path.exists(savepath): os.makedirs(savepath)
#y - moves picture donw
#x - move right
y=-.0005
x=.0003
f=plt.figure()
ax=plt.axes([.125,.5,.775,.4])
im = plt.imread(imgfile);
implot = ax.imshow(im,extent=[-123.155+x,-123.0+x,49.27+y,49.3275+y]);
plotcoast(ax,filename='pacific.nc',lw=2,color='r')
#plotcoast(ax,filename='pacific_harbour.nc',lw=2,color='b')
cl=loadkml('data/misc/vh_bathymetry/vh_harbour_coast.kml')
ax.plot(cl[:,0],cl[:,1],'b')
region={}
region['region']=[-123.1375,-123.08,49.283,49.304]
plot_box(ax,region,'g',1.5)
ax.axis([-123.155+x,-123.0+x,49.27+y,49.3275+y])
_formatter = mpl.ticker.ScalarFormatter(useOffset=False)
ax.yaxis.set_major_formatter(_formatter)
ax.xaxis.set_major_formatter(_formatter)
ax1=plt.axes([.125,.075,.775,.375])
implot = ax1.imshow(im,extent=[-123.155+x,-123.0+x,49.27+y,49.3275+y]);
plotcoast(ax1,filename='pacific.nc',lw=2,color='r')
plotcoast(ax1,filename='pacific_harbour.nc',lw=2,color='b')
ax1.plot(cl[:,0],cl[:,1],'b')
ax1.axis(region['region'])
ax1.yaxis.set_major_formatter(_formatter)
ax1.xaxis.set_major_formatter(_formatter)
plt.draw()
axsub1bb=ax1.get_axes().get_position().bounds
ax.annotate("",xy=(axsub1bb[0]+axsub1bb[2],axsub1bb[1]+axsub1bb[3]),xycoords='figure fraction',xytext=(region['region'][1],region['region'][3]), textcoords='data',arrowprops=dict(width=.5,shrink=0,color='g',headwidth=3))
ax.annotate("",xy=(axsub1bb[0],axsub1bb[1]+axsub1bb[3]),xycoords='figure fraction',xytext=(region['region'][0],region['region'][3]), textcoords='data',arrowprops=dict(width=.5,shrink=0,color='g',headwidth=3))
plt.savefig(savepath + 'coastline_overgoogle.png',dpi=300)
plt.close(f)