How to create spatial points with a pattern

I do some work where I need to create as a) random spatial points; b) nonrandom spatial points over a polygon, i.e. for b) the probability of points depends, for example, on the east-west gradient or on the distance from some point source or something else

For a) I can generate random points over the polygon using the command spsample()in the package spas follows:

# Load a spatial polygon from maptools package
library(maptools)
nc <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],        proj4string=CRS("+proj=longlat +datum=NAD27"))
plot(nc)

library(sp)
pts <- spsample(nc, 100, type="random")
plot(nc)
points(pts, pch=19, col="red")

This gives exactly what I want for a). But can this be changed for b), so that points are more likely in the East than the West, for example? (and while you can still indicate that I want 100 points?)

+4
1

, , spatstat. rpoint x, y, . , 0 100 :

library(maptools)
library(spatstat)
nc <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
                    proj4string=CRS("+proj=longlat +datum=NAD27"))
nc <- as.owin(nc)
west0 <- nc$xrange[1]
f <- function(x, y, ...){ 100 * (x - west0) }
pts <- rpoint(1000, f, win = nc)
plot(pts)

Intensity increase from West to East

+3

Source: https://habr.com/ru/post/1617090/


All Articles