3

I'm new to Spatstat for R and I'm trying to add a point layer to a window I've created from a polygon. I see questions like this have been asked before but I still can't get what I need from the responses given. So far I have:

##Run libraries: 
library(“spatstat”)
library(“maptools”)
library(“sp”)
library(“rgdal”)

##set the working directory
setwd(“Z:/CP/spatstat/data/”)

##read in the shapefiles
Points <- readOGR(getwd(), "MyPointShapefile")
StudyArea <- readOGR(getwd(), "MyPolygonShapefile")

##create the window from polygon shp
w <- as.owin(StudyArea)

How do I add the two together so the points are projected in the window?

0

1 Answer 1

3

Just coerce "Points" to a ppp object using "w" as the window.

w <- as.owin(StudyArea)
  pts.ppp <- as.ppp(coordinates(Points), w)
    plot(pts.ppp)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.