seq中的linearK错误。 default()不能是NA,NaN

时间:2017-08-07 14:57:13

标签: spatstat

我正在尝试从CRC spatstat书(第17章)学习一个小的linnet对象的linearK估计,当我使用linearK函数时,spatstat会抛出一个错误。我在下面的r代码的注释中记录了该过程。错误如下。

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对象有问题,但我发现很难解释错误以及如何解决它们。有人可以指导我吗?

由于

1 个答案:

答案 0 :(得分:0)

当我尝试在线性网络上绘制标记点图案时,我可以确认plot.lpp中存在错误。希望很快得到修复。您可以使用

绘制未标记的点图案
plot(unmark(d1_lpp))

我无法使用linearK重现问题。您正在运行哪个版本的spatstat?在我的笔记本电脑spatstat_1.51-0.073上的开发版本中,一切正常。最近对此代码进行了更改,因此可能会通过更新到开发版本来解决此问题(请参阅https://github.com/spatstat/spatstat)。