Hi, I am new of the forum (and of the use of Exiftool as well).
I am writing a simple loop in R to transform FLIR rJPG into temperature raster using the pakckage Thermimage by Glenn Tattersall. Here is my loop:
tau2_name<-paste0("DJI_0",seq(161,285,1),".jpg")
for(i in 1:length(tau2_name)){
f<-paste0("D:/thermal_data/Malaysia/drone/Day_3/9am/orig/",tau2_name)
img<-readflirJPG(f, exiftoolpath="installed")
d<-flirsettings(f,exiftoolpath="installed",camvals = " ")##notworking
h<- d$Info$RawThermalImageHeight
w<- d$Info$RawThermalImageWidth
tem<-raw2temp(img,E=0.96,OD=30,RTemp = d$Info$ReflectedApparentTemperature,ATemp = 25,
IRWTemp = d$Info$IRWindowTemperature,IRT = d$Info$IRWindowTransmission,
RH=65, PR1 = d$Info$PlanckR1,PB=d$Info$PlanckB,PF=d$Info$PlanckF,
PO=d$Info$PlanckO,PR2 = d$Info$PlanckR2,ATA1 = d$Info$AtmosphericTransAlpha1,ATA2 = d$Info$AtmosphericTransAlpha2,
ATB1 = d$Info$AtmosphericTransBeta1,ATB2 =d$Info$AtmosphericTransBeta2,ATX = d$Info$AtmosphericTransX)
fileraw<-paste0("D:/thermal_data/Malaysia/drone/Day_3/9am/calib/",i)
tem<-raster(tem)
writeRaster(tem,paste0(fileraw,".tif"),overwrite=T)
###
meta<-system2("C:/Users/Matteo/Documents/exiftool",f,stderr = T)
meta<-str_replace_all(meta,fixed(" "), "")
meta.df<-data.frame(meta)
g<-meta.df %>% separate(meta,c("A","B"),sep = ":",extra = "merge")
nec<-g[c(26:27,29,34:41,108:110),] #extract only the needed metadata
att<-paste0("-",nec$A,"=",nec$B)
system2("C:/Users/Matteo/Documents/exiftool",arg= paste0(att," ",paste0(fileraw,".tif")))
}
While the first part of the code works perfecly (up to the ###), the second part (that write metadata for the new images by extracting them from the original has a couple of problem):
-in the destination folder it creates for each image a file called name.tif_original. Exploring him I saw that is a file with the original metadata . Is there a way to avoid this file creation?
-I extract 14 tags from the original images; in the writing part it just write me the first 13, leaving the last (GPSLongitude); note that it perfectly write the GPSLatitude.
I hope to have been clear, and apologize for any error.
Add -overwrite_original to the exiftool options to avoid creating the "_original" file.
If it isn't writing the last tag, there must be something wrong with the command. Perhaps it needs a space after the last tag argument or something. If you can't figure it out, try adding a dummy tag at the end that you don't want to write.
- Phil