# How do I get the upstream distance to all points in a DEM from a single downstream point?

I want to get the upstream distance to all points in a DEM from a single downstream point. The goal is to create a "downstream distance to a point grid". This then would allow me to create "distance" contours upstream from a point in the watershed.

I tried using the Raster Calculator with this equation:

``````Outras = Con("Fdr" == 1,16,Con("Fdr" == 2,32,Con("Fdr" == 4,64,Con("Fdr" == 8,128,Con("Fdr" == 16,1,Con("Fdr" == 16,1,Con("Fdr" == 32,2,Con("Fdr" == 64,4,Con("Fdr" == 128,8)))))))))
``````

This "reverses" the flow direction in the `Fdr` grid, but doesn't really work.

Any suggestions?

-
Incidentally, there are many ways to shorten your raster calculator expression, such as Con("Fdr" >= 16, "Fdr"/16, "Fdr"*16). But you're right; that's no good as input to any flow-based calculation. Are you using a sufficiently recent version of SA that supports `PathDistance`? – whuber Dec 16 '11 at 21:49
Can't you use the "Flow Length" geoprocessing tool in hydrological toolset to do this? – dmahr Dec 16 '11 at 22:20
@dmahr is correct: the DOWNSTREAM option specifically does this: "Calculates the downslope distance along the flow path, from each cell to a sink or outlet on the edge of the raster." – whuber Dec 12 '12 at 18:19

## 1 Answer

To expand on my comment: use a combination of Flow Direction and Flow Length to calculate this value.

Flow Direction (illustrated below) calculates the direction water would immediately flow from a given pixel. Either north, northeast, east, southeast, south, southwest, west, or northwest.

Flow length uses the precalculated flow direction raster to calculate the distance traveled in the flow direction raster to the most upstream or downstream cell in the raster (depending on the `direction_measurement` parameter. In this case, you should use the `DOWNSTREAM` option for this parameter.

Now this is slightly different than what you are looking for, because you want the distance to from each cell to some cell downstream (the "destination cell") which is not necessarily the most downstream cell in the raster. To handle this, just subtract the output of the Flow Length tool by the value in the destination cell. The difference will be the desired distance.

Note that this assumes that all cells flow into the destination cell. If you have more complex hydrology, you should use the Watershed tool to subset your raster by the catchment area of interest.

-