[R-sig-Geo] as.im in spatstat::ppm not working as before
Alexandre Santos
@|ex@ndre@@nto@br @end|ng |rom y@hoo@com@br
Wed May 8 01:49:21 CEST 2024
Dear Members,
I'll calculate some old codes for a paper review, and I'm astonished that as.im() for fitting the Poisson model is not working as before. In my example:
library(raster)
library(spatstat)
# Elevation
r.grid.world <- raster('https://raw.githubusercontent.com/Leprechault/trash/main/wc2.1_10m_elev.tif')
proj4string(r.grid.world) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
r.grid.world.SGDF.F <- as(r.grid.world, "SpatialGridDataFrame")
#Fitting Poisson model
fit.c <- ppm(nztrees, ~ elev,
covariates=list(elev=as.im(r.grid.world.SGDF.F[[1]])))
#
# Error in as.im.default(r.grid.world.SGDF.F[[1]]) :
# Can't convert X to a pixel image
I tried as matrix and rotate, and the final real-valued pixel image didn't work as a covariate in the model.
Please, any help with it?
Thanks in advance
Alexandre
More information about the R-sig-Geo
mailing list