简体   繁体   English

使用 spatstat UK 将 Shape 文件从 GIS 转换为 PPP

[英]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.我正在尝试使用来自 GIS 的形状文件的我的研究区域(由单个多边形组成的大多边形)在 spatstat 中创建 PPP。

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我一直在关注:处理 spatstat 中的 shapeles package Adrian Baddeley、Rolf Turner 和 Ege Rubak 2022-11-08 spatstat 版本 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) #load packages install.packages("spatstat") library(spatstat) install.packages("maptools") library(maptools) #将收到关于 rgdal 的警告消息,坚持使用 maptools install.packages(sp) library(sp)

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

#check class class(UMshape1) #returned: [1] "SpatialPolygonsDataFrame #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) #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) #checked class 这些文件类型class(UM1) #"SpatialPolygons" class(UM1regions) #"list" class(UM1windows)

"list" “列表”

#from guidance 'The result is a list of objects of class owin. #from guidance '结果是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)通常将其转换为曲面细分 object 是有意义的,方法是键入': #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).最后一个命令 (tess) 现在已经运行了 48 小时(红色停止框)。 I did not created a progress bar.我没有创建进度条。

Is this the right thing to do so that I can then created my owin study area?这是正确的做法吗,这样我就可以创建我的 owin 学习区了? So that I can then create a PPP in spatstat?这样我就可以在 spatstat 中创建 PPP 了吗?

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.如果所需的结果是 class owin 中的单个owin用作点图案的 window,那么您不需要曲面细分。 Instead of teUM1 <-tess(tiles = UM1windows) you should probably do teWin <- union.owin(as.solist(UM1windows)) .而不是teUM1 <-tess(tiles = UM1windows)你应该做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) .如果您确实需要曲面细分(这将使每个 windows 分开以供进一步使用),那么您可以调用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 .计算时间长的原因是代码正在检查每个 window 是否与其他 windows 中的任何一个重叠。如果设置check=FALSE ,则禁用此检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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