-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_drone_metadata.R
101 lines (88 loc) · 3.14 KB
/
generate_drone_metadata.R
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# options(repos = c(ajlyons = 'https://ajlyons.r-universe.dev',
# CRAN = 'https://cloud.r-project.org'))
#
# install.packages('uasimg')
library(uasimg)
library(pagedown)
datadir <- "/run/media/sylvain/G2OI_1/ALDABRA" ### WITHOUT TRAILING /
sessdir <- "uav_2022_10_22_aldabra-passe-dubois_Mavic2Pro_" #### PATTERN CONTAINING DATA TO BE PROCESSED
origfolder <- getwd()
for (i in list.dirs(datadir , full.names = FALSE , recursive = FALSE)){
inputdir <- file.path(datadir, i)
if (grepl(sessdir, inputdir) == TRUE) {
print(paste("processing:", inputdir))
setwd(inputdir)
outputdir = file.path(inputdir, "METADATA")
flt1_info <-
uas_info(
file.path(inputdir, "DCIM"),
fp = TRUE,
# metadata = file.path( inputdir , "METADATA/metadata.txt"),
cache = TRUE,
update_cache = TRUE
)
flts_sum <- uas_report(
flt1_info,
thumbnails = TRUE,
# png_map = TRUE,
attachments = "mcp_kml",
report_title = paste(i, "Flight Summary"),
# report_rmd = system.file("report/uas_report_metrics.Rmd", package="uasimg"),
report_rmd = "/home/sylvain/build/uasimg/inst/report/uas_report_metrics.Rmd",
output_dir = outputdir,
overwrite_html = TRUE
)
# output_dir = "/home/sylvain/Documents/IRD/DATA/uav_2022_09_19_aldabra-arm01_Mavic2Pro_1/METADATA"
# fname = "Report_2022-10-19_18-17-02_202JPEGs.html"
# fn = "/home/sylvain/Documents/IRD/DATA/uav_2022_09_19_aldabra-arm01_Mavic2Pro_1/METADATA/Report_2022-10-19_18-17-02_202JPEGs.html"
#html_to_pdf(dir = output_dir)
# chrome_print(fn, format=c("pdf"))
for (i in list.files(outputdir))
{
if (endsWith(tolower(i), "html"))
{chrome_print(file.path(outputdir, i), format = c("pdf"))
}
}
uas_exp_shp(
flt1_info,
overwrite = TRUE,
output_dir = outputdir,
mcp = TRUE,
ctr = TRUE, # Centroid
fp = TRUE # Footprint
)
setwd(origfolder)
} # END SESSION SELECTION
} # END LOOP DATADIR
# library(terra)
# library(exactextractr)
# library(sf)
# #v <- vect("2022-10-19_18-17-02_202JPEGs_fp.shp")
# v <- st_read(dsn="2022-10-19_18-17-02_202JPEGs_fp.shp")
# set.seed(1)
# library(sp)
# pts <- spsample(v, n=200, type="random")
# plot(pts, add=TRUE, col="red")
# library(rgeos)
# polys <- gBuffer(pts, width=50000, byid=TRUE)
# plot(polys, add=TRUE, border="red")
# # gives something like USrelig.shp.
# library(rgeos)
# gO <- gOverlaps(v, polys, byid=c(TRUE, TRUE))
# dim(gO)
# #makes a logical matrix with TRUE where scot_BNG[i,] overlaps with polys[j].
# count_by_city <- apply(gO, 2, sum)
##### TOC ... TO BE DONE
# uas_toc(
# html_reports = flt1_info,
# output_dir = "/home/sylvain/Documents/IRD/DATA/uav_2022_09_19_aldabra-arm01_Mavic2Pro_1/METADATA"
# )
#
# ## Create TOC, copying all the individual HTML files to one place
# uas_toc(flts_sum,
# output_dir = "/home/sylvain/Documents/IRD/DATA/uav_2022_09_19_aldabra-arm01_Mavic2Pro_1/METADATA",
# toc_title = "Aldabra ARM01",
# # fltmap_base = TRUE,
# gather_dir = ".",
# overwrite_toc = TRUE,
# open_toc = FALSE)