Coded modular to deal with boundary density

based on occupancy data.
Compute the density automatically