Getting 90th percentile data of each plot for plant height

44 views
Skip to first unread message

Pravin Gautam

unread,
Jan 18, 2021, 11:48:06 PM1/18/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi Filipe,
New in R and or any other programming. Trying to your FieldImageR for drone image analysis for plant height. Following FIeldImageR code I can get EPH mean, median or quartile of each plots. However, how do I get percentile data of each plots for plant height. I want EPH to be 90th percentile plant height rather than mean, quartile or any other function under fun=. This is important as in many crops average plant height for drone images  do not correlates with actual ground data. Its 80th percentile or more is more correlated with actual height data.

fmatias

unread,
Jan 19, 2021, 12:08:00 AM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Hi Pravin,

Thank you for asking. Can you adept the code below for your data and let me know if it worked, please?

PH<-extract(x = DSM, y = fieldShape)

PH90<-do.call(rbind,lapply(PH, quantile, probs = c(0.9), na.rm=TRUE))

PH90

All the best,

Filipe

Pravin Gautam

unread,
Jan 19, 2021, 12:21:03 AM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Filipe,
which DSM to use. There is no DSM only. It started with DSM0 and DSM1 and followed by .R, .S etc. Irrespective of which one I put it gives me following error.

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘extract’ for signature ‘"list", "function"’

Pravin Gautam

unread,
Jan 19, 2021, 12:23:29 AM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
This is what I'm using.
# Estimating plant height
# Uploading files from soil base (EX_DSM0.tif) and vegetative growth (EX_DSM1.tif):
DSM0 <- stack("DSM0 HIYT 3-23.tif")
DSM1 <- stack("DSM1 HIYT 6-11.tif")

# Cropping the image using the previous shape from step 2:
DSM0.C <- fieldCrop(mosaic = DSM0,fieldShape = EX1.Crop)
DSM1.C <- fieldCrop(mosaic = DSM1,fieldShape = EX1.Crop)

# Canopy Height Model (CHM):
DSM0.R <- resample(DSM0.C, DSM1.C)
CHM <- DSM1.C-DSM0.R
plot(CHM)

# Rotating the image using the same theta from step 3:
CHM.R<-fieldRotate(CHM, theta = -0.979)

# Removing the soil using mask from step 4:
CHM.S <- fieldMask(CHM.R, mask = EX1.RemSoil$mask)

# Extracting the estimate plant height average (EPH):
EPH <- fieldInfo(CHM.S$newMosaic, fieldShape = EX1.Shape$fieldShape, fun = "mean")

EPH$plotValue

PH<-extract(x = CHM.S, y = fieldShape)

PH90<-do.call(rbind,lapply(PH, quantile, probs = c(0.9), na.rm=TRUE))

PH90

fmatias

unread,
Jan 19, 2021, 12:25:45 AM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Pravin,

Please try this new code:

PH90.A<-extract(x = CHM.S$newMosaic, y = EX1.Shape$fieldShape)

PH90<-do.call(rbind,lapply(PH90.A, quantile, probs = c(0.9), na.rm=TRUE))

PH90

Best,

Filipe    

Pravin Gautam

unread,
Jan 19, 2021, 9:14:00 AM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Thank you Filipe. It worked.

fmatias

unread,
Jan 19, 2021, 2:04:39 PM1/19/21
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Great Pravin..!!!

I just added some new code in the tutorial to extract 10% and 90% quantile: https://github.com/OpenDroneMap/FIELDimageR#P10 

Hope it helps.
All the best,
Filipe

Reply all
Reply to author
Forward
0 new messages