Skip to content
Prev 29383 / 29559 Next

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

as.im() was in maptools, which was retired last year. If you need to recreate old work, install maptools from source from the CRAN package archive
https://cran.r-project.org/src/contrib/Archive/maptools/.

For non-archival work, update the workflow. See also https://github.com/r-spatial/evolution/issues/8.

Hope this clarifies,

Roger

---
Roger Bivand
Emeritus Professor
Department of Economics
Norwegian School of Economics, Bergen, Norway

________________________________
Fra: R-sig-Geo <r-sig-geo-bounces at r-project.org> p? vegne av Edzer Pebesma <edzer.pebesma at uni-muenster.de>
Sendt: onsdag, mai 8, 2024 9:28:54 a.m.
Til: r-sig-geo at r-project.org <r-sig-geo at r-project.org>
Emne: Re: [R-sig-Geo] 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:
--
Edzer Pebesma (he/him)
Universit?t M?nster, Institute for Geoinformatics
Heisenbergstrasse 2, 48149 M?nster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=05%7C02%7CRoger.Bivand%40nhh.no%7Cd2a2b64634a7462f860708dc6f3082d5%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638507501339856786%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=6H%2F9HQ%2BV1nyf2AdWabq0eoG3b8zqCQEC3ZC%2BFoRYvUI%3D&reserved=0<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>