rsbivand / rgrass

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

initGRASS: no slot of name "ptr" for this object of class "SpatExtent" #80

Closed mikejohnson51 closed 9 months ago

mikejohnson51 commented 9 months ago

Hello @rsbivand ,

Thanks for this package!

I am experiencing an issue when running initGRASS using a SpatRast object as the SG input.

Using the example from the documentation yields the same error:

library(terra);library(rgrass)
#> terra 1.7.46
#> Loading required package: XML
#> GRASS GIS interface loaded with GRASS version: GRASS 8.2.1 (2023)
#> and location: file15cff26434d35

f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
loc <- initGRASS('/opt/local/lib/grass82', 
                 home=tempdir(), 
                 SG=r, 
                 override=TRUE)
#> Error in initGRASS("/opt/local/lib/grass82", home = tempdir(), SG = r, : no slot of name "ptr" for this object of class "SpatExtent"

Created on 2023-09-14 by the reprex package (v2.0.1)

The notion of s4 classes/pointers is marginally familiar to me but it seems the slot name in SpatRast objects is now pnt instead of ptr.

Could this be a hint of where the initiation is getting caught?

r@pnt
#> C++ object <0x7fc6c7d23b90> of class 'SpatRaster' <0x7fc6c785a2a0>

Things do work as expected when I convert the SpatRast to a SpatialGridDataFrame and use that as input.

If you have any advice it would be appreciated and thanks for everything you do for this community,

Mike

rsbivand commented 9 months ago

Fixed in https://github.com/rsbivand/rgrass/pull/79 and published on CRAN, please update and check, reporting back on whether this works for you.

mikejohnson51 commented 9 months ago

You are correct. I thought I had reinstalled the package but clearing messed something up in the testing. I can confirm 0.3.9 works for me. Thanks!