code: def erode_edge(dem, iterations=1):
      
      import scipy.ndimage as ndimage 
      print('Eroding pixels near nodata: %i iterations' % iterations)
      mask = np.ma.getmaskarray(dem)
      mask_dilate = ndimage.morphology.binary_dilation(mask, iterations=iterations)
      out = np.ma.array(dem, mask=mask_dilate)
      return out
docs: Erode pixels near nodata