FieldMask error

144 views
Skip to first unread message

panos pp

unread,
Oct 30, 2023, 2:21:18 PM10/30/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi to all
I have this error in fieldMask (R 4.3.1).

EX1.RemSoil<- fieldMask(mosaic = EX1.Rotated, Red = 1, Green = 2, Blue = 3, index = "HUE")

Error in (function (classes, fdef, mtable)  :

  unable to find an inherited method for function ‘nlyr’ for signature ‘"RasterStack"’


Any ideas?

Thank you

fmatias

unread,
Oct 30, 2023, 3:02:21 PM10/30/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hey there,

I think, it is because you are not using "terra" and function "rast" to call your data. Also, we are not rotating images anymore, in this case, if you rotate you nedd to use rast() after using fieldRotate. Could you try using the code below and follow the updated pipeline in https://github.com/OpenDroneMap/FIELDimageR

install.packages("devtools"
devtools::install_github("OpenDroneMap/FIELDimageR"
devtools::install_github("filipematias23/FIELDimageR.Extra")

library(FIELDimageR
library(FIELDimageR.Extra
library(raster
library(terra

EX1 <- rast("EX1_RGB.tif"
fieldView(EX1)

EX1.RemSoil <- fieldMask(mosaic = EX1, Red = 1, Green = 2, Blue = 3, index = "HUE")
EX1.Shape<-fieldShape_render(mosaic = EX1,ncols = 14, nrows = 9
fieldView(mosaic = EX1, fieldShape = EX1.Shape, type = 2, alpha = 0.2)

Hope it helps,
Filipe

panos pp

unread,
Oct 30, 2023, 5:48:12 PM10/30/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Thanks for your immediate answer.

Now I have this error:

> fieldView(mosaic = EX1, fieldShape = EX1.Shape, type = 2, alpha = 0.2)

[1] "Starting analysis ..."

Error in viewRGB(mosaic) : could not find function "viewRGB


What could it be?
Panos

pspawar

unread,
Oct 30, 2023, 10:39:59 PM10/30/23
to FIELD...@googlegroups.com
This issue might be due to the mapview library not being activated by you. The viewRGB function is a part of the mapview library. To ensure the proper functioning of FIELDimageR functions, please remember to load the necessary dependencies, including FIELDimageR.Extra, raster, terra, mapview, sf, and stars. 

Step:1
library(FIELDimageR)
library(FIELDimageR.Extra)
library(raster)
library(terra)
library(mapview)
library(sf)
library(stars)

Hope it helps.


--
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/2cbd54c9-ae1e-481f-a67b-bc6de54d90f9n%40googlegroups.com.

panos pp

unread,
Oct 31, 2023, 3:16:18 AM10/31/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Thank you
Everything is fine now.

Panos

fmatias

unread,
Oct 31, 2023, 7:10:45 AM10/31/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi there,

Maybe you need to install mapview and mapedit package.

EX1.RemSoil<- fieldMask(mosaic = rast(EX1.Rotated), Red = 1, Green = 2, Blue = 3, index = "HUE")

Also, you do not need to rotation "EX1.Rotated" - if you want to use it please use:

Best,
Filipe

pspawar

unread,
Nov 9, 2023, 1:16:28 AM11/9/23
to FIELD...@googlegroups.com
Hello! The 'fieldMask' function now requires a 'spatRaster' terra object instead of a 'RasterStack.' This update is part of FIELDimageR's transition to the modern "terra" package.The updated FIELDimageR relies on the "terra" package for raster operations instead of "raster". You may need to adapt your code accordingly. Refer to the updated tutorial on: https://github.com/filipematias23/FIELDimageR.Extra for more information. If you have any questions, feel free to ask..

--
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.
Reply all
Reply to author
Forward
0 new messages