Hello all potential helpers,
I have a SpatialPolygonDataFrame
object obtained from the tigris
package and I would like to use it as a polygonal window in the creation of a ppp
object. Here is what I tried:
# Needed packages
library(spatstat)
library(sf)
# Download geospatial data for Lee county in Alabama (home of the great Auburn University by the way!)
county <- tigris::county_subdivisions(state = "Alabama", county = "Lee")
# The polygon of Lee county is subdivided, so I convert it to a single polygon after converting it to an sf object
county_sf <- st_as_sf(county)
county_one <- st_union(county_sf)
# A quick plot of the object outputs what I am expecting
plot(county_one)
# Now I create a planar point pattern and I use county_one as the window
p <- ppp(x = -85.4, y = 32.5, window = as.owin((county_one)))
# But the plot here shows that the window is just a rectangle and not the polygon :(
plot(p)
Thank you for your help.