简体   繁体   中英

Converting Shape file from GIS into a PPP using spatstat UK

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM