Guest User

Untitled

a guest
May 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. def do_stats(self, exclude=(0, )):
  2. """ do some stats on the integer types in the array.
  3. returns the area of cells for each type found in the array.
  4. you can use this after masking to only calc inside the polygon.
  5. """
  6. raster_info = self.agoodle.raster_info
  7. classes = np.unique(self)
  8. cell_area = abs(raster_info.xsize * raster_info.ysize)
  9. stats = {}
  10. for cls in (c for c in classes if c not in exclude):
  11. stats[cls] = len(self[self == cls]) * cell_area
  12. return stats
Add Comment
Please, Sign In to add comment