Last active
March 11, 2022 09:40
-
-
Save simbamangu/4e99216e5a6160b050f62428292618ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the ground sample distance (cm/pixel) for oblique camera position. | |
# Sensor defaults for a Nikon D5600 with 35mm lens | |
# Inputs: | |
# Sw = sensor width in mm | |
# Sh = sensor height in mm | |
# f = focal length of lens in mm | |
# Pw = sensor width in pixels | |
# Ph = sensor height in pixels | |
# phi = off-nadir (directly below sensor) angle | |
# h = height of sensor above ground in metres | |
# Outputs: | |
# gsd.inner = closest band of image ground resolution in cm / pixel | |
# gsd.outer = furthest band of image ground resolution in cm / pixel | |
# width.inner = image width at closest point | |
# width.outer = image width at furthest point | |
# strip.width = perpendicular distance at centre of image | |
gsdOblique2 <- function(Sw = 23.2, f = 35, Sh = 15.4, phi = 45 * pi/180, h = 450/3.28, Pw = 6016) { | |
## Angle of view ---- | |
A.h <- 2 * atan((Sw / 2) / f) # horizonal angle of view° | |
A.v <- 2 * atan((Sh / 2) / f) # vertical angle of view° | |
## | |
h.1 <- h / cos(phi - A.v / 2) # length to lower edge of view | |
w.1 <- h.1 * Sw / f | |
h.2 <- h / cos(phi + A.v / 2) | |
w.2 <- h.2 * Sw / f | |
gsd.1 <- w.1 / Pw | |
gsd.2 <- w.2 / Pw | |
stripwidth <- sqrt(-h^2 + h.2^2) - sqrt(-h^2 + h.1^2) | |
return(data.frame(gsd.inner = gsd.1, gsd.outer = gsd.2, width.inner = w.1, width.outer = w.2, stripwidth)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment