0

Using help on this site I have already got the following code from where I can perform certain analyses. However, I'd now like to perform analyses on a certain variable (column z) within the point shapefile. To do this I need to establish 'marks' on column z (the 7th column). This column provides either a '4' or a '10', defining two types of point.

Can anyone assist?

##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)

##coerce the points to window
pts.ppp <- as.ppp(coordinates(Points), w)
plot(pts.ppp)
2

If the marks are created based off another attribute, then you could probably just use an if-else statement. You can simply create a new column by creating a variable ie.

Points$NewMarks <- ifelse(X, Y, Z)

Where:

X = Your argument (if statement), Y = Your then statement (for you: 4), and Z = Else statement (for you: 10)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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