Closed AB-Kent closed 2 years ago
Thanks for the clear reproducible example. I will discuss with @baddstats whether we should put in an argument in as.polygonal()
to handle logical masks with NA
values. I need to test how other functions using masks are behaving with NA
values.
In the design of spatstat
, a binary mask is a logical matrix, and NA
entries are not permitted.
If I understand the example, it originated from another package which does allow NA
entries in a mask.
Rather than changing the spatstat
software specification to allow NA
values in a mask (which could generate a lot of extra work and cause the package to slow down) it seems to me that the solution is that owin(mask=M)
should test for NA
entries in the matrix M
and convert them to FALSE
. Then in your example, the result of owin
will always conform to the spatstat
design, and as.polygonal
will not fall over.
Probably as.mask
should also be modified.
I agree, changing owin
to replace NA values is a better solution.
OK. This is implemented in the current development version spatstat.geom 2.3-0.013
and will be submitted to CRAN soon as 2.3-1
.
Thanks again for drawing this to our attention.
I ran into this when creating polygonal masks from matrices that had been clipped using
raster::mask
. It's fixable in client code by avoiding theNA
s, but maybeas.polygonal
should replaceNA
values in the mask withFALSE
, as done in this reprex?Created on 2021-11-29 by the reprex package (v2.0.1)