compute_count function

Count data at each location