I always get error to this when converting shapefile point to ppp spatstat that windowed by a polygon shapefile
# polygon that to be window neighborhoods <- st_read("neighborhoods/neighborhoods.shp") # convert CRS to planar projection as recommended by (https://stackoverflow.com/questions/59597078/use-sf-polygon-object-as-window-in-spatstat) neighborhoods_3857 <- st_transform(neighborhoods, crs = 3857) # point that to be PPP spatstat trees <- st_read("trees/trees.shp") # convert to planar projection trees_3857 <- st_transform(trees, crs = 3857)
The problems, the "trees_3857" doesn't have dataframe columns that represent in EPSG3857 coordinates, so Feature column of "trees_3857" doesn't have x and y columns that respect to EPSG 3857
q <- ppp(x=?, y=?, win=neighborhoods_3857)
what I have done but error
first =using as.ppp instead of ppp to convert a vector shp to ppp spatstat
test1 <- as.ppp(trees_3857, win=neighborhoods_3857) Error in as.ppp.sf(trees_3857, win = neighborhoods_3857): unused argument (win = neighborhoods_3857)
second = add geometries of "trees_3857" to feature columns with QGIS named "xcoord" & "ycoord"
test2 <- ppp(trees_3857$xcoord, trees_3857$ycoord, win = neighborhoods_3857) Warning message: "65217 points were rejected as lying outside the specified window"