Closed darrellcarvalho closed 1 year ago
Unsure if relatedly, but alternative dot densities (i.e. setting to 1000) result in an error:
Error in `map()`:
ℹ In index: 4.
Caused by error:
! [dots] 'size' is too small
Backtrace:
1. los_angeles_race %>% ...
15. terra::dots(., field = value, size = values_per_dot)
16. terra (local) .local(x, ...)
17. terra:::error("dots", "'size' is too small")
18. base::stop("[", f, "] ", emsg, ..., call. = FALSE)
@darrellcarvalho I was able to run your first example successfully, it just took a couple minutes. Perhaps give it a bit longer?
Regarding your second example, I can reproduce the error. The code that triggers the error in terra is here:
The error gets thrown if no dots are to be drawn for a given layer after rounding the data values divided by the size. As as_dot_density()
partitions the layer by group
to generate the dots, the Native American population in Los Angeles is too small for a values_per_dot
of 1000 as all values then round to 0.
This is worth some error handling in as_dot_density()
to explain.
@walkerke I think it was something to do with the instance I was operating on; a reboot and running fresh resulted in no hang. Glad that tinkering with it let me bring the terra aspect to your attention, though!
Code below hangs on execution of the
as_dot_density()
function call until R is terminated externally. Hennepin example from book still functions. My intuition is that it has something to do with empty geometries/NA values.