cost[i_sampled, ]) will contain NA if there are NA in the cost surface. This is fairly common when working with masked raster data or irregular areas that are surrounded by NA.
Setting na.rm=TRUE in the call to sum() seems like a reasonable solution, but will result in clearly sub-optimal sampling locations or locations outside of the non-NA pixels. Like this:
The contours were generated from the cost surface.
I suspect that any samples with NA cost should result in restarting of the sampling process. There must be an efficient way for constraining samples to the non-NA portions of the sampling domain.
Incidentally, .lhs_obj() seems to deal with NA just fine.
Sometimes 0's or NA (?) in the cost surface result in the following error:
It would appear that
metropolis_cost
is periodically set to NA.Digging deeper into
clhs.data.frame
, I see on lines:118
196
cost[i_sampled, ])
will contain NA if there are NA in the cost surface. This is fairly common when working with masked raster data or irregular areas that are surrounded by NA.Setting
na.rm=TRUE
in the call tosum()
seems like a reasonable solution, but will result in clearly sub-optimal sampling locations or locations outside of the non-NA pixels. Like this:The contours were generated from the cost surface.
I suspect that any samples with NA cost should result in restarting of the sampling process. There must be an efficient way for constraining samples to the non-NA portions of the sampling domain.
Incidentally,
.lhs_obj()
seems to deal with NA just fine.