Photogrammetry

Example 6.1,Page 281

In [1]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
Da=184.32;
Db=95.84;
Ax=-115.0
By=-115.0;

#calculation
phi=atan(Ax/By);
AB=sqrt(Ax**2+By**2);
theta=acos((Da**2+AB**2-Db**2)/2/Da/AB);
alpha=phi-theta;
xc=Da*cos(alpha)-115.0;
yc=-Da*sin(alpha);

#result
print "the coordiantes in mm x is",round(xc),"y is",round(yc,2)
the coordiantes in mm x is 64.0 y is -43.72

Example 6.2,Page 290

In [8]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
f=0.152;
H=1800;#elevation of topmost point
h=300;#elevation of ground

#calculation
S=f/(H-h);

#result
print  "scale of photograph in 1 in",round(1/S)
scale of photograph in 1 in 9868.0

Example 6.3,Page 290

In [13]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
f=0.150 #focal length
h1=1500.0;#elevation A
h2=1200.0;#elevation B
h3=1000.0;#elevation C
H=3000.0;#height

#calculation
hav=1.0/3*(h1+h2+h3);
S1=f/(H-h1);
S2=f/(H-h2);
S3=f/(H-h3);
Sav=f/(H-hav);

#result
print  "scale of point 1 in 1 in",round(1/S1);
print  "scale of point 2 in 1 in",round(1/S2);
print  "scale of point 3 in 1 in",round(1/S3);
print  "average scale  in 1 in",round(1/Sav);
scale of point 1 in 1 in 10000.0
scale of point 2 in 1 in 12000.0
scale of point 3 in 1 in 13333.0
average scale  in 1 in 11778.0

Example 6.4,Page 292

In [15]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
ab=188.0;
AB=120;
Sm=1.0/20000;

#calculation
S=ab/AB*Sm;

#result
print  "scale of photograph in 1 in",round(1/S)
scale of photograph in 1 in 12766.0

Example 6.5,Page 295

In [1]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
xa=45.35;
xb=-40.16;
f=152.4;#focal length
H=1500.0;#actual height
ha=200.0;#height A
hb=150.0;#height B
ya=38.41;
yb=-45.65;

#calculation
Xa=xa*(H-ha)/f;
Ya=ya*(H-hb)/f;
Xb=xb*(H-ha)/f;
Yb=yb*(H-hb)/f;
AB=sqrt((Xb-Xa)**2+(Yb-Ya)**2);

#result
print "distance of AB in m",round(AB,3)
distance of AB in m 1042.361

Example 6.6,Page298

In [2]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
d=62.4;#displacement
H=250.0;#height of datum
r=115.4;#image distance

#calculation
h=H*d/r;

#result
print "height of chimney in m",round(h,3)
height of chimney in m 135.182

Example 6.7,Page 299

In [3]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
ra=88.25;#image distance of A
rb=81.23;#image distance of B
rc=68.14;#image distance of C
H=2000.0;
ha=255;
hb=200;
hc=145;
f=0.1524;

#calculation
aa=ra*ha/H;
bb=rb*hb/H;
cc=rc*hc/H;
S=f/H;

#result
print "relief distance of A in mm",round(aa,2)
print "relief distance of B in mm",round(bb,2)
print "relief distance of C in mm",round(cc,2)
print  "scale of photograph in 1 in",round(1/S)
relief distance of A in mm 11.25
relief distance of B in mm 8.12
relief distance of C in mm 4.94
scale of photograph in 1 in 13123.0

Example 6.8,Page 300

In [4]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
f=0.1524;#focal length
S=0.08251/1000;#scale

#calculation
H=f/S;

#result
print "flying height in m",round(H,3)
flying height in m 1847.049

Example 6.9,Page 300

In [5]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
import numpy as np

#solving the quadratic polynomial in H
#0=0.4064-365.929H-289685.07
coeff=[0.4064, -365.929,-289685.926];
H=np.roots(coeff);

#result
print "height required in m",round(H[0],2)
height required in m 1407.02

Example 6.10,Page 309

In [2]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
S=1.0/10000;#scale
A=500.0;#area
pw=0.3;
l=0.23;
w=0.23;

#calculation
a=(1-0.6)*(1-pw)*l*w/S**2/1000/1000;
N=A/a;

#result
print "no. of photographs taken",round(N)
no. of photographs taken 338.0

Example 6.11,Page 310

In [7]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
L=25.0e3;
k=0.23e4;#l/s=w/s;
pl=0.6;
pw=0.3;
W=20.0e3;

#calculation
N=((L/((1-pl)*k)+1))*((W/((1-pw)*k)+1)+1);

#result
print "no. of photographs taken",round(N)
no. of photographs taken 406.0

Example 6.12,Page 310

In [3]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
f=0.1524;#focal length
S=1.0/10000;#scale
pw=0.3;#side lap
w=0.23;#format width
pl=0.6;
l=0.23;

#calculation
W=(1-pw)/S*w;
H=f/S+300;
N2=30/W+1;
N2=round(N2)
L=(1-pl)*1/S*l/1000;
T=3600*L/240.0;
Ad=T*240e3/60.0/60.0;#adjusted ground distance
N1=40.0e3/Ad+1;
N1=round(N1)
N=N1*N2;

#result
print "height over datum in m",H
print "no. of flight strips",round(N2-1)
print "length of each photograph cover in km",round(L,3)
print "exposure time in s",round(T)
print "no. of photographs taken",round(N)
height over datum in m 1824.0
no. of flight strips 0.0
length of each photograph cover in km 0.92
exposure time in s 14.0
no. of photographs taken 44.0

Example 6.12b,Page 317

In [4]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
t=3.0/180*pi;
ya=82.25;
xa=-62.45;
s=220;
f=152.4;#focal length
H=2500.0e3;
h=500.0e3;

#calculation
theta=s-180;
ya_dash=xa*sin(theta*pi/180)+ya*cos(theta*pi/180)+f*tan(t)
S=(f/cos(t)-ya_dash*sin(t))/(H-h);

#result
print  "scale of photograph in 1 in",round(1/S)
scale of photograph in 1 in 13246.0

Example 6.13,Page 319

In [12]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
t=3*pi/180;
xa=-62.45;
xb=78.25;
f=152.4;#focal length
H=2500.0;#actual height
hb=800#height B
ha=500.0;#height A
ya=82.25;
yb=-41.15;
s=220.0;

#calculation
theta=s-180;
ya1=xa*sin(theta*pi/180)+ya*cos(theta*pi/180)+f*tan(t); # ya'
xa1=xa*cos(theta*pi/180)-ya*sin(theta*pi/180); #xa'
xb1=xb*cos(theta*pi/180)-yb*sin(theta*pi/180); #xb'
yb1=xb*sin(theta*pi/180)+yb*cos(theta*pi/180)+f*tan(t); # yb'
Xa=xa1*(H-ha)/(f/cos(t)-ya1*sin(t));
Xb=xb1*(H-hb)/(f/cos(t)-yb1*sin(t));
Ya=ya1*cos(t)*(H-ha)/(f/cos(t)-ya1*sin(t));
Yb=yb1*cos(t)*(H-hb)/(f/cos(t)-yb1*sin(t));
AB=sqrt((Xb-Xa)**2+(Yb-Ya)**2);

#result
print "distance of AB in m",round(AB,3)
distance of AB in m 2307.753
 -100.708756369  78.25  82.25  -41.15  0.642787609687

Example 6.14,Page 324

In [10]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
ri=95.0;
f=152.4;
t=3*pi/180;
l=50*pi/180;

#calculation
dt=ri**2*sin(t)*cos(l)**2/(f-ri*sin(t)*cos(l));
                           
#result
print "tilt displacement of the image in mm",round(dt,2)
tilt displacement of the image in mm 1.31

Example 6.15,Page 351

In [1]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
d=230.0;#square side
f=152.4#focal length
pl=0.6;

#calculation
k=(1-pl)*d/f;
V=k/0.15;

#result
print "vertical exaggeration is",round(V,2)
vertical exaggeration is 4.02

Example 6.16,Page 360

In [13]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
xa=51.23;
xb=91.48;
ya=48.33;
yb=-51.63;
f=152.4;#focal length
B=425.0;#actual height
hb=842.86#height B
ha=820.97;#height A
r1=10.42;
r2=9.67;
b1=89.12;#b'
b=89.43;
ra=11.62;
rb=14.53;

#calculation
C=0.5*((b1-r1)+(b-r2))
pa=C+ra;
pb=C+rb;
Xa=B*xa/pa;
Xb=xb*B/pb;
Ya=ya*B/pa;
Yb=yb*B/pb;
AB=sqrt((Xb-Xa)**2+(Yb-Ya)**2);

#result
print "distance of AB in m",round(AB,3)
distance of AB in m 492.28

Example 6.17,Page 363

In [11]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
C=79.0;
ra=11.42;#elevarion in image
rb=15.65;#elevarion in image
hb=651;#height of B
H=1500;#height

#calculation
delp=ra-rb;#pa=ra+c and pb=rb+c so ra-rb=pa-pb
pa=ra+C;
ha=hb+delp/pa*(H-hb);

#result
print "height of A in m",round(ha,3)
height of A in m 611.282

Example 6.18,Page 364

In [12]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
B=741.0;
f=152.4;
pa=94.32;
ha=325;

#calculation
H=ha+B*f/pa;

#result
print "height in m",round(H,3)
height in m 1522.29

Example 6.19,Page 364

In [13]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
H=1632.0;
f=152.4;#focal length
pa=82.75;
ha=283;

#calculation
B=pa/f*(H-ha);

#result
print "width of air base in m",round(B,3)
width of air base in m 732.479

Example 6.20,Page 377

In [14]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
alpha=50.0;
beta=46.0;
f=300.0;
xa=24.0;
xb=30.0;
beta=46.0;

#calculation
dela=xa/f;
delb=xb/f;
A=alpha+dela*180/pi; #angle A
B=beta-delb*180/pi; #angle B
D=180-A-B;
AD=1300.0*sin(B*pi/180)/sin(D*pi/180);
Y=6/(sqrt(xa**2+f**2))*AD;
RD=60.12+Y;

#result
print "distance of AD in m",round(AD,2)
print "RL of D in m",round(RD,2)
distance of AD in m 843.34
RL of D in m 76.93

Example 6.21,Page 378

In [15]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
f=152.4;
L=120;#length
x1=40.0;
x2=-90.0;

#calculation
X=f*L/(x1-x2);
Y=L*x1/(x1-x2);
h=X*(30-20)/f;

#result
print "the coordinates of D in m is X=",round(X,2),"Y =",round(Y,2);
print "elevation of D in m",round(h,2)
the coordinates of D in m is X= 140.68 Y = 36.92
elevation of D in m 9.23

Example 6.22,Page 380

In [16]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
f=150.4;
xc=-32.43;
xd=9.52;

#calculation
thc=atan(xc/f);
thd=atan(xd/f);
th=thd-thc;
th=th*180/pi;
Az=325+15.0/60+th;
Az=deg_to_dms(Az);

#result
print "Azimuth of D in deg,min,sec respectively",Az
Azimuth of D in deg,min,sec respectively [341, 2, 23.9]

Example 6.23,Page 382

In [2]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
BC=66.0;
AC=81.6;
xb=3.0;
ya=1.25;
xa=3.3;
theta=23+43.0/60;

#calcualtions
f=(xa+xb)/2/tan(theta*pi/180)+sqrt((xa+xb)**2/4/(tan(theta*pi/180))**2+xa*xb);
aa=atan(ya/sqrt(xa**2+f**2))
Va=AC*tan(aa);
ab=atan(-1.87/sqrt(xa**2+f**2));
Vb=-BC*tan(ab);

#result
print "focal length in cm",round(f,2)
print "horizontal distance in m",round(Vb+Va,2)
focal length in cm 15.0
horizontal distance in m 14.68

Example 6.24,Page 383

In [3]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
Eab=300.0;#average elevation
f=152.4;
xa=28.4;
xb=-22.5;
ya=24.5;
yb=38.4;
Ha=2322.0;
ha=400.0;
hb=200.0;
ab=61.05;
AB=810;

#calculation
Ha=300+AB/ab*f;
Xa=round((Ha-ha)/f*xa,2);
Xb=round((Ha-ha)/f*xb,2);
Ya=round((Ha-hb)/f*ya,2);
Yb=round((Ha-hb)/f*yb,2);
AB=sqrt((Xa-Xb)**2+(Ya-Yb)**2);
H=300+810/AB*(Ha-Eab);
Xa=(H-ha)/f*xa;
Xb=(H-ha)/f*xb;
Ya=(H-hb)/f*ya;
Yb=(H-hb)/f*yb;
AB1=sqrt((Xa-Xb)**2+(Ya-Yb)**2);

#result
print "Xb is calculated wrong in the book that resulted in the error"
print "length AB in m", round(AB,2)
print "corrected length AB in m", round(AB1,2)
print "flying height in m",round(H,3)
length AB in m 670.47
corrected length AB in m 816.12
flying height in m 2742.807

Example 6.25,Page 386

In [12]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
AB=300.0;
ab=102.4;
f=152.4;#focal length
hab=320.0;
d=7.8;
r=75.4;

H=hab+AB/ab*f;
h=d*H/r;

#result
print "height difference in m",round(h,2)
height difference in m 79.29

Example 6.26,Page 386

In [14]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
f=152.4;
b=74.25;
ht=100.0;
H=700.0;#flying height

#calculation
B=b*H/f;
pb=f*B/H;
pt=f*B/(H-ht);
delp=pt-pb;
ht=delp/pt*(H);

#result
print "error due to parallax in mm",round(delp,2)
print "height of chimney in m",round(ht,2)
error due to parallax in mm 12.38
height of chimney in m 100.0

Example 6.27,Page 387

In [17]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    sd=round(sd,2)
    return [d, m, sd]
B=180.0;
f=120.0;
pa=54.32
pb=46.35;

#calculation
delH=B*f/pa/pb*(pa-pb);

#result
print "height difference in m",round(delH,2)
height difference in m 68.38

Example 6.28,Page 387

In [35]:
#initialisation of variable
from math import pi,sqrt,acos,asin,atan,cos,sin,tan
L1=30000.0;
pl=0.6;
k=12000.0*0.2;#=l/S and w/S
pw=0.3;
W1=24000;

#calculation
N=round(((L1/((1-pl)*k)+1)+1))*round(((W1/((1-pw)*k)+1)+1));
Nf=N/33-1;#flight strips
gd=(1-pl)*k;#grounf distance
I=gd/(200e3)*60.0*60.0;#exposure interval
ad=round(I)/60.0/60*200e3;#actual distance

#result
print "no. of photographs taken",round(N)
print "no. of flight strips",Nf
print "ground distance in m",round(gd,2)
print "exposure interval in s", round(I)
print "actual distance in m",round(ad,2)
no. of photographs taken 528.0
no. of flight strips 15.0
ground distance in m 960.0
exposure interval in s 17.0
actual distance in m 944.44