It's not clear from your image if you want to extract all the cells along the edge, what you have numbered. Only 3 & 5 end at the blue barrier whilst 1, 2 and 4 run alongside and I presume flow off the edge at their downstream limit?
You do not state which GIS system you are using! So I shall assume ArcMap.
Here is one suggested work flow, there may be better ideas out there?
Here is a flow accumulation grid with a "barrier", all the cells of the barrier are 1:
Here is the flow accumulation thresholded to create a stream network
- I run the barrier dataset through an IsNull tool that creates a new raster that is 1 where it was null and 0 where it had a value, as show below
- Run the barrier raster through the Expand tool to expand by 1 pixel. In the image below the result of the Expanded grid is shown as pink with a slight transparency.
- Multiply the result of IsNull by the result of the Expand raster, this creates a raster as such:
This creates an "edge" raster which is overlapping your flow accumulation raster by 1 pixel.
- Now using the CON tool you can extract out all the flow accumulation cells that overlap the edge cells (where they equal 1), creating this raster:
- Finally using that stream network you first created use the CON tool again to pull out from the extracted flow accumulation cells that overlap the stream network. These are shown as red and green against the barrier and retain their flow accumulation values.