Good Morning, Sir can i get to know the codes for calculating all the indices specially the NDVI for a field trial.

81 views
Skip to first unread message

ImrAn Khan

unread,
Mar 15, 2021, 12:03:17 PM3/15/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Good Morning, Sir can i get to know the codes for calculating all the indices specially the NDVI for a field trial.

fmatias

unread,
Mar 15, 2021, 12:18:30 PM3/15/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi there,

The code/equation/formula to calculate vegetation indices are described in this table: https://github.com/OpenDroneMap/FIELDimageR#P6

As you can see for NDVI is NDVI=(NIR-R)/(NIR+R)

Best,
Filipe

ImrAn Khan

unread,
Mar 15, 2021, 12:26:35 PM3/15/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Sir, this did not help me. I am facing aproblem in calculation of NDVI. Can i get all the codes please.
Regards
IMRAN KHAN

fmatias

unread,
Mar 15, 2021, 12:37:36 PM3/15/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
I am not understanding your question. Could you send the error here?

About the code, the only code that I have is the code that you already have when you installed the package

In other words, I have the same code that everyone else has when installing the package. 

Filipe

ImrAn Khan

unread,
Mar 15, 2021, 11:36:46 PM3/15/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Sir i used these codes, what changes shall i make to calculate the other indices such as NDVI:

library(FIELDimageR)

library(raster)

 

EX1<-stack("C:/Users/dell/Downloads/EX2_RGB.tif")

plotRGB(EX1, r = 1, g = 2, b = 3)

EX1.Crop <- fieldCrop(mosaic = EX1)

EX1.Rotated<-fieldRotate(mosaic = EX1.Crop, clockwise = F, h=F)

EX1.Rotated<-fieldRotate(mosaic = EX1.Crop, theta = 2.3)

source(system.file("extdata", "fieldRotate.R", package = "FIELDimageR"))

EX1.Rotated<-fieldRotate(mosaic = EX1.Crop, theta = 2.3, extentGIS=TRUE)

EX1.Indices<- fieldIndex(mosaic = EX1.RemSoil$newMosaic, Red = 1, Green = 2, Blue = 3, index = c("NGRDI","BGI"), myIndex = c("(Red-Blue)/Green"))

EX1.Indices.myIndex<- fieldIndex(mosaic = EX1.RemSoil$newMosaic, Red = 1, Green = 2, Blue = 3, index = c("NGRDI","BGI"), myIndex = c("(Red-Blue)/Green","Red/Green","Blue/Green"))


So sir how can i get the NDVI??

Regards 

IMRAN KHAN                           


fmatias

unread,
Mar 16, 2021, 11:05:27 AM3/16/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi Imran Khan,

To calculate indices as NDVI or NDRE it is necessary a multispectral image/mosaic (with RedEdge and/or NIR bands besides the traditional RGB). First, you need to inform the function fieldIndex() which layer in your mosaic represents the RedEdge (e.g., layer 4 in the mosaic) and NIR (e.g., layer 5 in the mosaic). Then on the parameter "index", you can write any index (e.g., NDVI and NDRE) from the table available in this link: https://github.com/OpenDroneMap/FIELDimageR#P6

Here is an example of code to calculate NDVI and NDRE:

EX1.Indices<- fieldIndex(mosaic = EX1.RemSoil$newMosaic,
                                            Red=1,Green=2,Blue=3,
                                            RedEdge=4,
                                            NIR=5, 
                                            index = c("NGRDI","BGI","NDVI","NDRE"))

Also, there is more information about multispectral in this link: https://github.com/OpenDroneMap/FIELDimageR#P14

Best,
Filipe

Prasanth Chigurupati

unread,
Mar 16, 2021, 12:31:58 PM3/16/21
to FIELD...@googlegroups.com
Hello Imran,

Here is the YouTube link (https://youtu.be/2khnveYFov8), where you can clear your confusion.

Thank you

--
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/e805f17a-9bdf-4248-ab83-0275988be1f7n%40googlegroups.com.

ImrAn Khan

unread,
Mar 17, 2021, 1:50:05 AM3/17/21
to FIELD...@googlegroups.com
  Error in fieldIndex(mosaic = EX1.RemSoil$newMosaic, Red = 1, Green = 2,  :
  RedEdge and/or NIR is/are not available in your mosaic

Sir i'm facing this error while executing this particular query.

Virus-free. www.avg.com

--
You received this message because you are subscribed to a topic in the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/FIELDimageR/gwV16Ad3buU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to FIELDimageR...@googlegroups.com.

fmatias

unread,
Mar 17, 2021, 10:15:30 AM3/17/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Imran,

You need to inform which bands are the RedEdge and NIR. The easy solution, if you have a multispectral image (5 bands order: R, G, B, RedEdge, and NIR), is to include RedEdge=4 and NIR=5 in the function fieldIndex().

EX1.Indices<- fieldIndex(mosaic = EX1.RemSoil$newMosaic,
                                            Red=1,
                                            Green=2,
                                            Blue=3,
                                            RedEdge=4,
                                            NIR=5, 
                                            index = c("NGRDI","BGI","NDVI","NDRE"))

Best,
Filipe

ImrAn Khan

unread,
Mar 17, 2021, 10:18:11 AM3/17/21
to FIELD...@googlegroups.com
Sir how to inform which bands are the RedEdge and NIR.

Virus-free. www.avg.com

ImrAn Khan

unread,
Mar 17, 2021, 10:27:20 AM3/17/21
to FIELD...@googlegroups.com
Sir the same error is being prompted again:

Error in fieldIndex(mosaic = EX1.RemSoil$newMosaic, Red = 1, Green = 2,  :
  RedEdge and/or NIR is/are not available in your mosaic

fmatias

unread,
Mar 17, 2021, 10:54:20 AM3/17/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Imran,
The number (e.g., 1, 2, 3, 4, and 5) in front of the band's name in the function fieldIndex() means the sequence of those bands in your picture. Imagine a multispectral image with 5 bands (e.g, Red, Green, Blue, RedEdge, and NIR) each band is represented for example by:

Red=1
Green=2
Blue=3
RedEdge=4
NIR=5 

Where Red=1 means that the first layer/band of your multispectral image (with 5 layers) represents the region RED (e.g., 600-680 nm) of the spectrum capture by your sensor/camera.  Green=2 means the region GREEN (e.g., 480-600 nm). Blue=3 means the region BLUE (e.g., 400-480 nm). RedEdge=4 means the region RED-EDGE (e.g., 680-750 nm). And NIR=5 means the region NIR (e.g., >750 nm).

Hope it makes sense.

Best,
Filipe

ImrAn Khan

unread,
Mar 23, 2021, 11:14:20 PM3/23/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Sir, i couldn't get you. I need some more help in this.
May i share the image so that you can help me with the index calculation??

fmatias

unread,
Mar 24, 2021, 11:33:25 AM3/24/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi Imran,

Sure... Please send your image here and we will try to figure out what's going on.

Best,
Filipe

ImrAn Khan

unread,
Mar 25, 2021, 11:39:27 PM3/25/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Sir, i'm attaching the image of the trial plot below. Please find the attached image. Will be waiting for you response to my problems. thank you sir.
EX6_RGB.JPG

fmatias

unread,
Mar 26, 2021, 11:18:08 AM3/26/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Hi Imran,

Unfortunately, you can’t calculate NDVI.

 The image that you shared is an RGB image with three layers (Red, Green, and Blue). To calculate NDVI or NDRE you need a Multispectral image with Red-Edge and NIR layers besides the RGB.


 Here, there are some nice reviews to help you to understand the difference:

·       https://doi.org/10.3389/fpls.2017.01111

·       https://doi.org/10.1016/j.tplants.2013.09.008

·       https://doi.org/10.1016/j.tplants.2018.11.007


 Using FIELDimageR and your image you can calculate other RGB indices as “BI”, “SCI”, “GLI”, “HI”, “NGRDI”, “SI”, “VARI”, “HUE”, and “BGI” (https://github.com/OpenDroneMap/FIELDimageR#P6). For example, using the code below:

  

### START ###

 library(FIELDimageR)

library(raster)

EX1<-stack("EX6_RGB.JPG")

plotRGB(EX1)

EX1.Indices<- fieldIndex(mosaic = EX1, Red = 1, Green = 2, Blue = 3, index = c("NGRDI","BGI"))

 ### END ###

  

Hope this explanation helps you.

Best,

Filipe

ImrAn Khan

unread,
May 10, 2021, 10:44:55 PM5/10/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Good Morning sir, Sir i had a query. Sir how can i generate a CSV table for the image for this particular image?
EX6_RGB.JPG
Reply all
Reply to author
Forward
0 new messages