Incorrect Index calculation in FieldImageR?

91 views
Skip to first unread message

Artūrs Katamadze

unread,
Oct 4, 2023, 1:01:54 PM10/4/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hello,

I'm seeing an issue with calculations of indices. After shaping the plots and running indices I get an output for each band such as Blue, Green, Red, RedEdge, NIR and my selected indices. I noticed the error when in my output .csv I see Inf instead of an actual value, so I decided to manually use the values from each band to calculate the index. The difference is pretty big, so the question is if FIeldImageR is calculating the indexes correctly or am I missing something? 

Here is an excel with some data to cross check the error. 

Best,
Artūrs Katamadze
EX1.Info.csv

fmatias

unread,
Oct 4, 2023, 1:59:05 PM10/4/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi  Artūrs ,

Hope everything is going right over there...!

Thanks for your question ... All indices are being calculated according to the table here: https://github.com/OpenDroneMap/FIELDimageR#p6

You can see the equations in the package here: https://github.com/OpenDroneMap/FIELDimageR/tree/master/inst/extdata

Data extraction using FIELDimageR::fieldInfo() uses raster::extract(). Check the code on the line 33 here: https://github.com/OpenDroneMap/FIELDimageR/blob/master/R/fct_fieldInfo.R

Data extraction using FIELDimageR.Extra::fieldInfo_extra() uses terra::extract(). Check the code on the line 29 here: https://github.com/filipematias23/FIELDimageR.Extra/blob/main/R/fct_fieldInfo_extra.R

terra::extract is faster than raster::extract and there are many materials online comparing both...!

If you are using the same shapefile (plot grid) between calculated (manual) and automatic indices (FIELDimageR) it is supposed to not see differences in values per plot if the equation is the same (manual x FIELDimageR). Small differences are common when comparing  terra::extract and raster::extract.

If you are extracting data in R or QGIS values may change a bit due to the extraction methods, but not much.

Just check if you are using the same grid.file, extraction method, and indices equation.

Let us know what you find out ... ok 

Thanks a lot and hope it helps,
Filipe

Artūrs Katamadze

unread,
Oct 4, 2023, 6:22:36 PM10/4/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
The calculation and the formula seems right, my next guess is that something is wrong with my orthomosaic. I notice that an extra band is appearing (Maize.1.1_7) while MicaSense Altum has only the first 6. Also, the range for several indices is weird like for TVI, RVI, VARI (as seen in the added image).  I can however use each of the values from Blue, Green, Red, RE and NIR to later calculate these indices in an excel with good values so it leads me back to the calculation. A bit lost here. 

Also, when I try using the new FIELDimageR Extra I am unable to fieldView() or plotShape() where I am receiving  "Error in seq.default(x$from, x$to) : 'to' must be a finite number"


Best,
Artūrs

P.S. Hope your talk today went well Filipe! :D  

Untitled.png

fmatias

unread,
Oct 8, 2023, 7:12:59 PM10/8/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi  Artūrs, 

Thanks for sharing ... Could you share your code, please? 

I want to check what numbers you are using to sign layers ... If the layers are misspelled the values will be wrong.

Hope it helps...! 

Best,
Filipe

Yussif Baba Kassim

unread,
Oct 9, 2023, 1:02:22 AM10/9/23
to FIELD...@googlegroups.com
Hi Artūrs,
My understanding of how FIELDimageR works is that for each plot, calculations are done on pixel basis but the output you export into an excel file is a summary (median, minimum, maximum, or mean which is the default) of all the pixels in the plot. So depending on the summary statistic you select in R, the output could be entirely different when compared to the manual calculations from excel.

Another thing is that, since the values you get in excel including red, green, blue, etc. bands are summary statistics, whatever index you calculate from these is a summary from those summaries. So your indices values from excel could be way different from the indices values you get from FIELDimageR which are calculated pixel-wise before summarizing.

I hope this helps,
Yussif.

--
You received this message because you are subscribed to the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this group and stop receiving emails from it, send an email to FIELDimageR...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/FIELDimageR/e804b7ea-adea-4b83-87a4-59182cf08e22n%40googlegroups.com.

Artūrs Katamadze

unread,
Oct 9, 2023, 8:34:08 AM10/9/23
to FIELD...@googlegroups.com
Hi Filipe!

Thanks for the reply! Here is my full code. 
Note that I am not using remove soil rotate or crop functions, because I have already prepared the exact field in Agisoft. 
In the end I decided to use the raw values of Blue/Green/Red/RE/NIR and later calculate the indices I need in an excel file. Seems to work. 
I am also attaching the example orthomosaic from the MicaSense Altum camera. I consider each line of maize a plot with some leaves from other lines entering.
#Import Orthomosaic
EX1 <- stack("Maize 1-14.tif")
#Import data table with plot identifier
DataTable<-read.csv("DataTable.csv",header = T)
#assign field map from data table
fieldMap<-fieldMap(fieldPlot=DataTable$Plot, fieldColumn=DataTable$Row, fieldRow=DataTable$Range, decreasing=T)
#Shape the imported orthomosaic with the data table
EX1.Shape<-fieldShape(mosaic = EX1, ncols = 1, nrows = 24, fieldMap = fieldMap)
#Calculate indeces
EX1.Indices<- fieldIndex(mosaic = EX1, Red = 3, Green = 2, Blue = 1,  NIR = 5, RedEdge = 4,
                         index = c("NDVI"))
##Additional indeces - "BI", "SCI", "GLI", "HI", "NGRDI", "SI", "VARI", "HUE", "BGI", "PSRI", "NDVI", "GNDVI", "RVI", "NDRE", "TVI", "CVI", "EVI", "CIG", "CIRE", "DVI" 

#Extract index data
EX1.Info<- fieldInfo(mosaic = EX1.Indices,fieldShape = EX1.Shape$fieldShape,n.core = 12)

#Save CSV
write.csv(EX1.Info$fieldShape@data,file = "EX1.Info.csv",col.names = T,row.names = F)



Best,
Artūrs

--
You received this message because you are subscribed to the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this group and stop receiving emails from it, send an email to FIELDimageR...@googlegroups.com.

pspawar

unread,
Oct 9, 2023, 11:08:37 AM10/9/23
to FIELD...@googlegroups.com

Hi  Artūrs, 

Thanks for sharing your code and orthomosaic. There seems to be an issue with the orthomosaic generation. It is incomplete and lacks essential properties, such as minimum and maximum values. It may be helpful to review the process of creating an orthomosaic from your raw images. Hope it helps...!

EX1

class      : RasterStack

dimensions : 2799, 1821, 5096979, 7  (nrow, ncol, ncell, nlayers)

resolution : 0.00633518, 0.00633518  (x, y)

extent     : 103.716, 115.2524, -11.56315, 6.169022  (xmin, xmax, ymin, ymax)

crs        : +proj=geocent +datum=WGS84 +units=m +no_defs

names      : Maize.1.1_1, Maize.1.1_2, Maize.1.1_3, Maize.1.1_4, Maize.1.1_5, Maize.1.1_6, Maize.1.1_7

 

When you check the tutorial image properties, you'll see this (the min, max values, :

EX1

class      : RasterStack

dimensions : 1353, 477, 645381, 3  (nrow, ncol, ncell, nlayers)

resolution : 0.06256, 0.06256  (x, y)

extent     : 296600.6, 296630.4, 4888177, 4888261  (xmin, xmax, ymin, ymax)

crs        : +proj=utm +zone=16 +datum=WGS84 +units=m +no_defs

names      : EX1_RGB_1, EX1_RGB_2, EX1_RGB_3

min values :  7.062500,  7.171875,  5.285156

max values :  232.9180,  172.9883,  160.1172




Artūrs Katamadze

unread,
Oct 10, 2023, 11:21:20 AM10/10/23
to FIELD...@googlegroups.com
Hi Filipe!

How do you obtain your orthomosaics? I am following the official Agisoft Altum tutorial found here Link
I also tried building orthomosaic with WebODM both rgb and multispectral and in all cases I don't see these min/max values.
I guess you are using Pix4D


Best,
Artūrs


Artūrs Katamadze

unread,
Oct 16, 2023, 1:12:11 PM10/16/23
to FIELD...@googlegroups.com
Yeah, no idea ive tried several ways but im still not getting the min/max values. This is probably the cause for  Error in seq.default(x$from, x$to) : 'to' must be a finite number   when using FieldImageR Extra.

Anyone has any clue? 


Best,
Artūrs
Reply all
Reply to author
Forward
0 new messages