rsbivand / rgrass

Interpreted interface between the GRASS geographical information system and R
https://rsbivand.github.io/rgrass/
26 stars 9 forks source link

error with segmentation.grass() #39

Closed LBorgers closed 2 years ago

LBorgers commented 2 years ago

I'm trying to segment a tif-file using grass and the following code:

initGRASS("E:/GRASS GIS 7.8", tempdir(), override=TRUE) #path to GRASS windows PC

LINUX

initGRASS("/usr/lib/grass78", home = tempdir(), gisDbase = tempdir(), location = "xtagle(tempfile())", mapset = "user1(tempfile())", override = TRUE) #path to GRASS Linux cluster

LOAD IMAGE AND VECTOR TO GRASS

load.to.grass("./data/Cropped_droneIMG.tif", "RGB")

SET REGION PARAMETER TO MATCH RGB

execGRASS("g.region", parameters= list(raster="RGB.1")) execGRASS("g.region",flags="p")

MAKE GROUP (needed for segmentation)

make.group.grass(c("RGB.1", "RGB.2","RGB.3"),"group-1")

PERFORM SEGMENTATION

segments<-segmentation.grass(group="group-1",ext=NA,min.size=50,threshold=0.05) #min.size: grouping of pixels, threshold: similarity, higher values bigger segments

at first the segmentation seems to work but in the end returns an error: image

This seems similar to this problem: https://github.com/rsbivand/rgrass/issues/27

I've tried to run grass in R with OSgeo4w but it did not work.

Cheers, Leendert

rsbivand commented 2 years ago

Please only raise strictly rgrass7 issues here, and always provide sessionInfo() output. The failing function is not from this package. Please provide a minimal reproducible example without unknown packages or functions. Please do not use images to report problems, they are often illegible. Please repeat outside RStudio.

It may be the proj.db version issue, but running rgrass7::getLocationProj() by itself would check that, and I assume you are running 0.2-6, which was believed to resolve that problem.

LBorgers commented 2 years ago

Thank you, and my apologies for the bad problem description. I thought segmentation.grass was a grass function but that was an imported function. Running segmentation in my own script works!