UAS Phenotyping and Aerial Image Acquisition Procedure for DJI

From Poland Lab Wiki
Jump to: navigation, search

Applications of DJI cameras for capturing video over plots.

Example

Generating flight plans for Litchi App for use with DJI video cameras

library(geosphere)
options(digits=8)
 
## input file with four corners
## corner should be numbered 11, 12, 21, 22
input = read.csv("~/htp/17ASH/17ASH_AM-panel_corners.csv", header=TRUE, check.names=FALSE)
 
 
 
## number of ranges in field plan
nrange = 25
 
## buffer / additional buffer in m
buffer = 6
 
lat.dif = (input$Y[input$id==11] - input$Y[input$id==21])/ (nrange-1)
lon.dif = (input$X[input$id==11] - input$X[input$id==21])/ (nrange-1)
 
waypoints = matrix(data=NA, nrow=nrange*2, ncol=2)
 
colnames(waypoints)=c("lon", "lat")
waypoints[1,]=c(input$X[input$id==11], input$Y[input$id==11])
waypoints[2,]=c(input$X[input$id==12], input$Y[input$id==12])
 
for (i in 3:(nrange*2)){	
	if(i%%4==3 | i%%4==1){waypoints[i,] = waypoints[i-1,]-c(lon.dif,lat.dif)}
	if(i%%4==0 | i%%4==2){waypoints[i,] = waypoints[i-3,]-c(lon.dif,lat.dif)}
}
 
 
## add passes on end (outside of plots)/ if needed for imaging buffer around outside of field
nExtra = 3
 
for (i in 1:(nExtra*2)){
	if(i%%4==3 | i%%4==1){waypoints = rbind(waypoints[1,]+c(lon.dif,lat.dif),waypoints)}
	if(i%%4==0 | i%%4==2){waypoints = rbind(waypoints[3,]+c(lon.dif,lat.dif),waypoints)}
 
	if(i%%4==3 | i%%4==1){waypoints = rbind(waypoints, waypoints[nrow(waypoints),]-c(lon.dif,lat.dif))}
	if(i%%4==0 | i%%4==2){waypoints = rbind(waypoints, waypoints[nrow(waypoints)-2,]-c(lon.dif,lat.dif))}
 
}
 
 
 
## adjust waypoints w/ uniform buffer
n = c(1:nrow(waypoints))
right = n%%4==1 | n%%4==0
left = n%%4==2 | n%%4==3
 
waypoints[right,] = destPointRhumb(waypoints[right,], 180, buffer)
waypoints[left,] = destPointRhumb(waypoints[left,], 0, buffer)
 
 
## check the map of the points
plot(waypoints[,1], waypoints[,2])
points(input$X, input$Y, pch=24, cex=2)
 
 
 
 
write.csv(waypoints, file="~/htp/17ASH/17ASH_AM-panel_Litchi-waypoints_columns-45m.csv")