0

I am trying to create a PPP in spatstat using my study area (a large polygon made up of individual polygons) from a shape file from GIS.

I have been following: Handling shapeles in the spatstat package Adrian Baddeley, Rolf Turner and Ege Rubak 2022-11-08 spatstat version 3.0-2

#load packages install.packages("spatstat") library(spatstat) install.packages("maptools") library(maptools) #will get warning message about rgdal instead, stick with maptools install.packages(sp) library(sp)

#import shapefile UMshape1<-readShapeSpatial('F:/GIS/export_shape/Clipped_urban_matrix.shp')

#check class class(UMshape1) #returned: [1] "SpatialPolygonsDataFrame

#following code from guidance to convert Objects of class SpatialPolygonsDataFrame UM1 <- as(UMshape1, "SpatialPolygons") UM1regions <- slot(UM1, "polygons") UM1regions <- lapply(UM1regions, function(x) { SpatialPolygons(list(x)) }) UM1windows <- lapply(UM1regions, as.owin)

#checked class of each of these file types class(UM1) #"SpatialPolygons" class(UM1regions) #"list" class(UM1windows)

"list"

#from guidance 'The result is a list of objects of class owin. Often it would make sense to convert this to a tessellation object, by typing': #so I enter the code for my data teUM1 <-tess(tiles = UM1windows)

This last command (tess) has now been running for 48 hours (red stop box). I did not created a progress bar.

Is this the right thing to do so that I can then created my owin study area? So that I can then create a PPP in spatstat?

markalex
  • 8,623
  • 2
  • 7
  • 32

1 Answers1

1

If the desired result is a single window of class owin to use as the window for your point pattern, then you don't need a tessellation. Instead of teUM1 <-tess(tiles = UM1windows) you should probably do teWin <- union.owin(as.solist(UM1windows)).

If you do really need a tessellation (which would keep each of the windows separate for further use) then you could call tess(tiles=UM1windows, check=FALSE). The long computation time is caused by the fact that the code is checking whether each window overlaps any of the other windows. This check is disabled if you set check=FALSE.

Adrian Baddeley
  • 2,534
  • 1
  • 5
  • 8
  • Thank You for this @Adrian. I will be honest and say I am not sure if I need a tessellation. I am converting a shape file from GIS into a study area to assign my window (1623 Km2). Due to the fact its a shape file from GIS its pulled over lots of polygons making up my study area. Its the study area as a whole that I need to set up as my window owin. – Juniper Jan 23 '23 at 12:23
  • I will run the new code to set up owin for my ppp using teWin <- union.owin(as.solist(UM1windows)). Can I just then run standard ppp code using new teWin as owin? Or would I need: ppp(x, y, poly) for polygonal window? I apologise for my lack of technical ability using spatstat – Juniper Jan 23 '23 at 12:23