Skip to content
Prev 29382 / 29559 Next

as.im in spatstat::ppm not working as before

r.grid.world.SGDF.F[[1]] is a numerical vector, not even a matrix, so 
clearly as.im.default doesn't know what it should do with it.

Maybe there was once a method as.im for r.grid.world.SGDF.F, which is of 
class SpatialGridDataFrame, but no longer - software evolves.

A way you could approach this is converting that object to a stars object:

 > library(stars)
Loading required package: abind
Loading required package: sf
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
 > as.im(st_as_stars(r.grid.world.SGDF.F))
Error: Only projected coordinates may be converted to spatstat class objects

and that points you to another issue you have: spatstat works with data 
in Cartesian coordiantes (R2), not with geodetic coordinates (S2). So 
that's a helpful error message.
On 08/05/2024 01:49, Alexandre Santos via R-sig-Geo wrote: