I have about 6000 long/lat points representing the location of health centers in the US. I want to color a map of the US according to the distance to the nearest health center. On my last post, I got a SUPER helpful suggestion to use distmap() in the spatstat package (Thanks!!). Now I need help using distmap(), ppp() and owin().
The "distance map" of a set of points A is the function f whose value f(x) is defined for any two-dimensional location x as the shortest distance from x to A. In my case, A is the points identifying the 6000 health centers and I want f(x) for every point on the US map.
I believe I would do this by defining A, health center locations, as a ppp object, with the associated window being a map of the US. So, here's a simple example of distmap(), ppp() and owin():
##define A as 20 random points in a 1x1 window and make distance map, z; plot A <- ppp(runif(20),runif(20),window=owin(xrange=c(0,1),yrange=c(0,1)) z <- distmap(A) plot(z)
I need help substituting real long/lat points for "unif(20),runif(20)" and converting a map of the US to a owin() object. Can anyone help?