0

I have a numpy array as given, corresponding to x,y coordinates. I am searching for a way to convert this into ppp point structure to perform spatial analysis using spatstat tool in R via rpy2.

points=array([[ 181.124067 ,   58.2029135],
       [  17.9539667,  123.397744 ],
       [ 173.539929 ,   24.6389491],
       ..., 
       [ 250.767528 ,  182.099229 ],
       [ 250.049724 ,   11.2006333],
       [ 228.186125 ,  251.200863 ]])

Ideally I would like to convert this into ppp using rpy2. I also tried to write numpy into csv and read that into R. However it still doesn't recognize it as ppp structure.

Mehtab Pathan
  • 443
  • 4
  • 15
  • You'll have to do a bit of homework and read the R documentation for the spatial statistics tool you are trying to use. In particular, you'll be interested in how the `ppp` objects are created. Once you have this, you just call it from `rpy2`. – lgautier Apr 27 '15 at 18:56
  • Yes, according to documentation you just need to do load the spatstat package (`library(spatstat)`) and do `pattern = ppp(x, y, c(xmin,xmax), c(ymin,ymax))` if the points are observed in the rectangular region [xmin,xmax]x[ymin,ymax]. For an irregular observation region (window) you need to use the argument `window`. – Ege Rubak Apr 30 '15 at 11:41

0 Answers0