I've got a predicted stream network raster with cells values 0 (not a stream) and 1 (is a stream). My end goal is to create a network of connected polylines, but unfortunately there are some areas that are disconnected that we want to include in the final file, and some we do not - we have decided to get rid of any segments disconnected from the larger network by more than 2 cells.

Therefore, I would only like to keep the cells with value 1 that are either 1. connected to the larger network or 2. within 2 cells (~40ft) of this main network. The areas circled in green below are what we're hoping to maintain, while removing the areas circled in red.

initial stream line raster showing orphans and disconnected "true" streams

I have tried using Spatial Analyst --> Region Group then reclassification (using a cutoff of count = 7) to remove the "orhpans" as we call we them, but that also gets rid of some areas that shouldn’t be cut, like a segment that’s short but only disconnected by 1 or 2 cells. See image below - areas in red should be maintained but are not.

product of Region Group reclassification

I understand why using the cutoff of 7 wouldn't necessarily work, as it would cut out small segments that are disconnected by 1 or 2 cells. I'm not sure what approach I SHOULD use, however.

  • I think your question will attract quicker and easier to apply answers (and more votes) if you edit one or other of your two parts out into a separate question. We mention the desirability of one question per question in the Tour.
    – PolyGeo
    Oct 22, 2014 at 2:54
  • I've answered part 1. please split your question so that it can be useful to others.
    – radouxju
    Oct 22, 2014 at 6:16

1 Answer 1


As a remark, topological problem are better solved with vector, but in this case there is a raster-based solution. For instance you convert to lines 'raster to lines), then you use "extend line" with a tolerance

use "expand" of one pixel to create a buffer around all your lines. Then you can do your region group and remove small parts (e.g. reclassify with threshold = 20, remember you have "buffers") for isolated groups. Finally, assuming that rivers are 1 and background is zero, you multiply the original with the cleaned buffer (or use a conditional). Alternatively, you can use "Thin" as a last step, which might slightly modify your lines but keeps the connectivity of nearby segments.

  • Thank you for your response. I may not completely understand what you're suggesting, as multiplying the original will give me zeroes where they shouldn't be again. (Something that became a "1" in the new file would become "0" again when multiplied by the old.) This method does connect everything I need connected, but unfortunately both thin and shrink were ineffective. I am open to a vector-based solution if necessary. Can you recommend an approach? The lines produced by converting the initial raster are not ideal, so I thought about manipulating a point file based on the raster.
    – troubbble
    Oct 29, 2014 at 20:04
  • I am focusing on your first figure: removing red and keeping green). the expand will be larger than the original. expanding by one will "connect" pixels with a gap smaller than 3 pixels. You then remove all the group of pixels that are too small, then you clean up.
    – radouxju
    Oct 29, 2014 at 20:23
  • I see the issue now. I not only need to keep the areas in green, I need to connect them to form a continuous network. I did not make that clear. I feel like I should ask about connecting those segments as a separate question.
    – troubbble
    Oct 29, 2014 at 21:19

Your Answer

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

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