2017-08-07 56 views
0

我想从CRC spatstat书(第17章)中学习线性K估计的小型Linnet对象,并且当我使用linearK函数时,spatstat会引发错误。我已经在下面的r代码的注释中记录了这个过程。错误如下。seq中的linearK错误。 ()不能是NA,NaN

Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite 

我不明白如何解决这个问题。我下面这个过程:

# I have data of points for each data of the week 
# d1 is district 1 of the city. 
# I did the step below otherwise it was giving me tbl class 
d1_data=lapply(split(d1, d1$openDatefactor),as.data.frame) 

# I previously create a linnet and divided it into districts of the city 
d1_linnet = districts_linnet[["d1"]] 

# I create point pattern for each day 
d1_ppp = lapply(d1_data, function(x) as.ppp(x, W=Window(d1_linnet))) 
plot(d1_ppp[[1]], which.marks="type") 

# I am then converting the point pattern to a point pattern on linear network 
d1_lpp <- as.lpp(d1_ppp[[1]], L=d1_linnet, W=Window(d1_linnet)) 


d1_lpp 
Point pattern on linear network 
3 points 
15 columns of marks: ‘status’, ‘number_of_’, ‘zip’, ‘ward’, 
‘police_dis’, ‘community_’, ‘type’, ‘days’, ‘NAME’, 
‘DISTRICT’, ‘openDatefactor’, ‘OpenDate’, ‘coseDatefactor’, 
‘closeDate’ and ‘instance’ 
Linear network with 4286 vertices and 6183 lines 
Enclosing window: polygonal boundary 
enclosing rectangle: [441140.9, 448217.7] x [4640080, 4652557] units 

# the errors start from plotting this lpp object 
plot(d1_lpp) 

"show.all" is not a graphical parameter 
Show Traceback 
Error in plot.window(...) : need finite 'xlim' values 

coords(d1_lpp) 


x y seg tp 
441649.2 4649853 5426 0.5774863 
445716.9 4648692 5250 0.5435492 
444724.6 4646320 677  0.9189631 
3 rows 

然后因此,我也linearK(d1_lpp)

Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite 

我觉得LPP对象有问题出现错误,但我觉得很难解释的错误,以及如何解决它们。有人能指导我吗?

感谢

+0

我们需要访问您的数据或使用内置数据集或人工生成的数据以提供帮助的可重复示例。 –

+0

我已将数据添加到此链接。 [数据](https://drive.google.com/open?id=0B_2R6KanT3YIQmxFTGVUaVAxYkk)。谢谢。 – BKS

回答

0

我可以证实试图绘制直线网络上的标记点图案时有一个bug在plot.lpp。希望尽快解决。您可以绘制使用

plot(unmark(d1_lpp)) 

我不能linearK重现该问题未标记的点模式。您正在运行哪个版本的spatstat?在我的笔记本电脑的开发版本spatstat_1.51-0.073一切正常。最近这个代码已经发生了变化,所以很可能这将通过更新到开发版本来解决(参见https://github.com/spatstat/spatstat)。

+0

我正在使用常规的cran版本。我已经安装从github和linearK似乎工作。我会做更多的实验。谢谢。 – BKS