error creating shapefile

106 views
Skip to first unread message

Stewart Morley

unread,
Nov 1, 2023, 4:44:33 PM11/1/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Thank you for updating FieldImageR! I have found that the updates mostly work although I keep running into this problem when creating a shapefile:

Error in if (!st_is_longlat(stars_object) && nlyr(mosaic) > 2) { : missing value where TRUE/FALSE needed

I'm not sure how to fix this error. The code I'm running is as follows:

#A package to analyze orthomosaics
library(FIELDimageR)
library(FIELDimageR.Extra)
library(raster)
library(terra)
library(mapview)
library(sf)
library(stars)

#Load the image
EX1 <- rast("04-24-23-orthophoto.tif")
# Visualization Option-02 (raster)
plotRGB(EX1, r = 1, g = 2, b = 3)

#Remove the soil
EX1.RemSoil <- fieldMask(mosaic = EX1, Red = 1, Green = 2, Blue = 3, index = "HUE")
#Build the shape file
EX1.Shape <- fieldShape_render(mosaic = EX1,ncols = 6, nrows = 21)


Everything works until I try to build the shapefile at which point I get the errror mentioned above. Interestingly, I get the same error if I try using fieldView(EX1) to visualize my plot. I don't get the same errors if I use plotRGB(EX1, r = 1, g = 2, b = 3).


Any help would be greatly appreciated!

Stewart Morley

Filipe Matias

unread,
Nov 1, 2023, 5:02:37 PM11/1/23
to FIELD...@googlegroups.com
Hi there,

Try running this code with rast():

#Build the shape file
EX1.Shape <- fieldShape_render(mosaic = rast(EX1),ncols = 6, nrows = 21)

We already updated fieldMask() on FIELDimageR. Maybe you need to upgrade your version.

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

Hope it helps…!

All the best,
Filipe 


--
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/abb26c2d-1e4f-49b8-a13f-e6896c505135n%40googlegroups.com.

Stewart Morley

unread,
Nov 1, 2023, 6:47:43 PM11/1/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Unfortunately that didn't work. I have freshly installed and updated all the packages needed for FieldImageR as well as FieldImageR.Extra

I still get the same error but now with the additional warning:
> #Build the shape file, currently setup to look at single DSLR images
> EX1.Shape <- fieldShape_render(mosaic = rast(EX1), ncols = 6, nrows = 21)
[1] "Starting analysis ..." Error in if (!st_is_longlat(stars_object) && nlyr(mosaic) > 2) { : missing value where TRUE/FALSE needed In addition: Warning message: [readValues] raster has no values

I've tried this with individual images taken from a digital camera as well as orthophotos assembled in WebODM from drone imagery.

Stewart Morley

unread,
Nov 10, 2023, 10:27:13 AM11/10/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
I've done some tinkering and it seems to be some issues related to the fieldView function. When loading a regular .jpg I get the errors mentioned in previous posts. However when I load the example file (EX1_RGB.tif) from the Github docs, everything seems to work. I can still run functions like RemSoil on regular .jpg files but I can't create shapefiles without getting the previous errors. It would be nice to still have this functionality so I could calculate canopy coverage from close-up camera shots that generate .jpg files.

Is there a particular set of conditions/parameters input files need in order to function well with FieldImageR?

pspawar

unread,
Nov 10, 2023, 11:11:31 AM11/10/23
to FIELD...@googlegroups.com
Hi..
The 'fieldView' function supports GIS images. It is  seems that your jpg file does not have crs. If your .jpg file lacks a coordinate reference system (crs), try assigning one using crs(img) = "epsg:3857". Afterward, attempt fieldview(img). Please let us know if this resolves the issue.

Stewart Morley

unread,
Nov 10, 2023, 12:30:46 PM11/10/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Assigning crs as epsg:3857 may have worked but I still get the same errors from before:
Error in if (project & !sf::st_is_longlat(x)) { : missing value where TRUE/FALSE needed

This seems odd because when I run the following I get this:
> st_is_longlat(EX1) 
[1] FALSE 

fmatias

unread,
Nov 10, 2023, 12:49:28 PM11/10/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi there,

Could you upload again the packages?

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

But now for your .jpg images you will run this code before:

EX<-rast("Image.jpeg")
  EX<-imgLAB(EX)
fieldView(EX)

Let us know if it worked...!

All the best,
Filipe

Stewart Morley

unread,
Nov 10, 2023, 3:40:52 PM11/10/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Thank you for the response but unfortunately that didn't fix the error. I made sure to reinstall and reload all packages but I'm still faced with the same error when I try to pass my image to fieldView.

pspawar

unread,
Nov 10, 2023, 8:50:51 PM11/10/23
to FIELD...@googlegroups.com
Could you please share your image? It's not clear which specific issue is causing the problem. It will help us in fixing any bugs in the code.

Stewart Morley

unread,
Nov 13, 2023, 3:13:06 PM11/13/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Sure, here is one taken from a DSLR camera. This will cause the same error and warning to occur when trying to run the fieldView or fieldShape function:

Error in if (!st_is_longlat(stars_object) && nlyr(mosaic) > 2) { : missing value where TRUE/FALSE needed In addition: Warning message: [readValues] raster has no values

I have also tried passing single images from DJI drones with GIS data included and still run into the same errors.
IMG_7336_CerealRye.JPG

Dr P S Pawar

unread,
Nov 14, 2023, 4:01:36 AM11/14/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Please try the FIELDimageR_JPG code into your workflow and check if it resolves the issues you're experiencing with the DSLR camera image. If you encounter any specific challenges or have further questions about implementing the code, feel free to contact us.

FIELDimageR_JPG.R

Stewart Morley

unread,
Nov 14, 2023, 3:22:16 PM11/14/23
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
That seems to have worked! I can extract canopy coverage data from stills now!

It does seem to create shapefiles although I can no longer see them like I could in previous versions of R similar to what other users have posted.

Reply all
Reply to author
Forward
0 new messages