Here is a very simple example. If you want further details, don't hesitate to ask me again
library(raster)
library(NetLogoR)
# Raster of 0.01
r <- raster(xmn = 0, xmx = 1.5, ymn = 0, ymx = 0.5, resolution = c(0.01, 0.01))
r[] <- runif(n = length(r))
plot(r)
# WorldMatrix of resolution 1 with the same number of rows and columns
nrow(r)
ncol(r)
# Either
myWorld <- createWorld(1, 150, 1, 50, data = r[])
# or
myWorld2 <- createWorld(0, 149, 0, 49, data = r[])
# You can start your coordinates wherever you want but you need to keep the same number of rows and colums
# Or you can directly use this function from NetLogoR
myWorld3 <- raster2world(r)
# Build your model with myWorld (or myWorld2 or myWorld3, it works the same)
# But keep in mind that your previous distance of 1.5 is now equal of 150 (100 times longer
# because of your resolution of 0.01 which is 100 times smaller than the resolution of 1 of the worldMatrix)
# So for example if you want to move your individuals of a real distance of 0.03, they need to move a distance of 3 cells
myTurtles <- createTurtles(n = 10, coords = randomXYcor(myWorld, n = 10))
plot(myWorld)
points(myTurtles, pch = 19)
myTurtles <- fd(turtles = myTurtles, dist = 3, torus = TRUE, world = myWorld)
points(myTurtles, pch = 19, col = "red")
# Rotate the turtles (not impacted by the resolution) and then move them of a real distance of 1
# so a distance of 100 in the worldMatrix
myTurtles <- right(turtles = myTurtles, angle = runif(n = 10, min = 0, max = 360))
myTurtles <- fd(turtles = myTurtles, dist = 100, torus = TRUE, world = myWorld)
points(myTurtles, pch = 19, col = "green")
# For example, add 10 to patches where there are turtles
myWorld <- NLset(world = myWorld, agents = patchHere(world = myWorld, turtles = myTurtles),
val = of(world = myWorld, agents = patchHere(world = myWorld, turtles = myTurtles)) + 10)
plot(myWorld)
# Then, at the end of your whole simulation (more complicated than this short example)
# if you want your output map to be the same resolution as before you can switch back to your raster layer
myNewRaster <- r
myNewRaster[] <- myWorld[]