0

I have a csv file with number of points. The data is included longitude, latitude and date. I classified my data based on the season (spring, summer, autumn and winter). I need to calculate the Ripley’s L for each season. I used Lest() from package spatstat in R. I could plot Ripley’s L using this function. But the range of x axis (distance) for each plot (season) is different. How can I make all four plots (seasons) in the same range (distance)?

sa  <- readOGR(".", "boundary")  # Don't add the .shp extension

W   <- as(sa, "owin")

Summer.ppp <- as(Sum_UTM, "ppp")

Autumn.ppp <- as(Autumn_UTM, "ppp")

Winter.ppp <- as(Winter_UTM, "ppp")

Spring.ppp <- as(Spring_UTM, "ppp")


Summer <- Lest(Summer.ppp, correction="Ripley")
plot(Summer , xlab="distance (m)", ylab="K(d)", cex.lab= 2, cex.axis=2)
plot(Summer, . -r ~ r, ylab=expression(hat("L")), xlab="distance (m)",cex.lab= 2, cex.axis=2)


Autumn <- Lest(Autumn.ppp, correction="Ripley")
plot(Autumn, xlab="distance (m)", ylab="K(d)", cex.lab= 2, cex.axis=2)
plot(Autumn, . -r ~ r, ylab=expression(hat("L")), xlab="distance (m)",cex.lab= 2, cex.axis=2)

Winter <- Lest(Winter.ppp, correction="Ripley")
plot(Winter, xlab="distance (m)", ylab="K(d)", cex.lab= 2, cex.axis=2)
plot(Winter, . -r ~ r, ylab=expression(hat("L")), xlab="distance (m)",cex.lab= 2, cex.axis=2)

Spring <- Lest(Spring.ppp, correction="Ripley")
plot(Spring , xlab="distance (m)", ylab="K(d)", cex.lab= 2, cex.axis=2)
plot(Spring, . -r ~ r, ylab=expression(hat("L")), xlab="distance (m)",cex.lab= 2, cex.axis=2)
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Holly
  • 1
  • 1
  • Please [edit](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) your post. – NelsonGon Jun 12 '19 at 06:14
  • Parameter for controling the extent of axes in `plot` should be `xlim` and `ylim`. See [here](https://stackoverflow.com/questions/23050927/r-language-how-to-set-ylim) on how to use it. – Roman Luštrik Jun 12 '19 at 06:42

1 Answers1

0

You write that you have latitude and longitude, but at the same time your datasets are named something with "UTM", which would indicate that you have planar x,y coordinates. Which is it? In spatstat you can only work with planar coordinates. You don't declare which packages you are using. The as function above to convert to ppp is probably from maptools? In that case I think the window of the ppp is just set to the bounding box of the coordinates. You have an object called W which you would probably want to use as the window of the ppp. You can do something like:

Window(Spring.ppp) <- W

As mentioned in the comments you can simply specify xlim = c(lower,upper) in the call to plot, where lower and upper are the numeric values of the limits you want on the x axis.

Ege Rubak
  • 4,347
  • 1
  • 10
  • 18
  • I was wondering do you have any idea that how long the process does it take? Let's say for like 2000 points ? because I did what you said but it just kept running without any outcome? thanks – Holly Jun 13 '19 at 05:31
  • How long which part takes? Assigning the correct observation window to the `ppp` usually takes a fraction of a second. What is the output of `print(W)`? And does `plot(W)` plot the region you are expecting? – Ege Rubak Jun 13 '19 at 21:04