ropensci / NLMR

📦 R package to simulate neutral landscape models 🏔
https://ropensci.github.io/NLMR/
65 stars 17 forks source link

Is it possible to create something like a regular spatial distribution with NLMR? #82

Open bniebuhr opened 2 years ago

bniebuhr commented 2 years ago

Hello,

I am exploring different spatial patterns as simulated scenarios and I was wondering if it is possible to have a regularly spaced pattern with NLMR. Maybe something like multiple focii regularly spaced among each other, with the intensity of the values decreasing as we go far from the centers. This is common in spatial point patterns but it would be nice to have raster representations of that.

Even though regular distributions might not be so common in nature, they might be for anthropogenic infrastructure (e.g. a representation of a wind park with regularly spaced wind tubines), so I see usefullness on that...

Any ideas or suggestions on that?

marcosci commented 2 years ago

😄 Hi there!

Any chance that you have a visual aid of what you aim to achieve? I can't actually make a picture in my head from what you want.

Could it be that you want to merge nlm_curds with a gradient or mpd?

bniebuhr commented 2 years ago

Hi!

Sorry for not giving a clear example earlier. Here it is an example, see if this makes sense to you.

library(raster)
library(landscapetools)
library(dplyr)

# create regular points
r <- raster::raster(xmn = 0, xmx = 100,
                    ymn = 0, ymx = 100, 
                    resolution = 10)
pts <- as.data.frame(r, xy = TRUE)[1:2]

# rasterize points
res(r) <- 1
r_pts <- raster::rasterize(pts, r, field = 1)

# plot points
landscapetools::show_landscape(r_pts)

# create pattern, e.g. gaussian neighborhood analysis
gf <- raster::focalWeight(r, 2, "Gauss")
nlm_regular <- raster::focal(r_pts, w = gf, na.rm = TRUE, pad = TRUE) %>% 
  raster::calc(fun = function(x) x/max(x)) # rescale

# plot "neutral" regular landscape
landscapetools::show_landscape(nlm_regular)

image

Maybe it violates the idea of a "neutral landscape model" - the only thing that could vary in this case is the number or density of points. But in some cases I see it might be useful to have such spatial patterns to compare theoretical results with those of random or clumped landscapes, for example.