I want to clean up a calculated flow distance raster and need some ideas on how to do it.

As you can see in the picture, there are some pixels along streets and rivers (gray) that show connection (Red circle). These are the ones I want to get rid off.

Single pixels further away from the streets or rivers should not get deleted. Pixels close to streets/rivers within the bigger cluster areas should not be deleted.

Therefore, I am looking for a way to select pixels with only 2 neighbor pixels along the streets and delete them.

I'm thinking about a workflow like this:

  1. Select all Pixels close to the streets and rivers
  2. Calculate how many pixels are close to each pixel (White are NoData)
  3. Delete if pixel only touches 2 other pixels

enter image description here

2 Answers 2


I believe that what you are after is a sieve approach. There have been a few previous decision on GIS StackExchange (eg., Avoid NoData After FocalMajority, Generalize Land Use Classification) on using sieve to eliminate errant pixels. There are implementations of this approach in ERDAS, GDAL and ArcGIS (using the Geomorphometry & Gradient Metrics Toolbox). Also, here is an answer that provides procedural details for implementing a sieve model in ArcGIS.

  • Thanks for the answer but it was not exactly what I was looking for I think.
    – loloj0
    Oct 24, 2018 at 11:52

I was able to solve the problem as follows:

  1. Reclassified my raster to 1 and NoData values
  2. Used Focal Statistics with SUM the Number of Pixels next to each pixel (Since all pixels are value 1)
  3. Used Focal Statistics to get the MAXIMUM value in the neighbourhood
  4. Reclassified the Raster
  5. Raster to Polygon: This gives a nice Polygon around the Data (See Picture 1)
  6. With Buffer I created smaller Polygons and with the Near Tool selected the Polygons that are close to the Streets (See Picture 2)

These Polygons can now be used to delete the wanted pixels

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.