# ArcGIS - Flow directions in the 4 cardinal directions only (North, East, South and West)

I would like to know if there is a way to calculate the flow directions in the 4 cardinal directions only (North, East, South and West). Indeed, ArcGIS transfers the flows in the 8 directions, which I don't want.

Does anyone have any idea how to proceed?

• Thanks for the answer. That's exactly what I'm looking for. Could you post the code because in the subject you indicate, it seems to me that it is not there. – Raphaël Sep 2 '18 at 8:13
• This is because he replied to my post half year later with advise to post solution. It's like dealing with a bot. – FelixIP Sep 2 '18 at 8:24
• Yes, it's true, it's not right. It would really help if you would send me your code. Thank you in advance. – Raphaël Sep 2 '18 at 8:36
• Tomorrow, if I have time. – FelixIP Sep 2 '18 at 9:45

Rotate your cost raster (DEM) by 45 degrees using any point in the middle. Set env. extent and cell size to ROTATED. Derive rows and columns rasters using technique described here.

Call rasters accordingly and find diagonal cells:

``````arcpy.gp.RasterCalculator_sa('("ROWS"*1261+"COLUMNS")%2', "C:/SCRATCH/chessboard")
``````

I used 1261 here because max(COLUMNS)=1260 in my case. Number must be odd. Make sure output looks like that:

Modify ROTATED using:

``````arcpy.gp.RasterCalculator_sa('Con("chessboard" == 1,"ROTATED","ROTATED"+10)', "C:/SCRATCH/pilars")
``````

to force diagonal directions. Fill PILARS, derive Flow Directions and flow paths. Use flow direction to convert paths to polylines.

Un-rotate polylines to see:

I used this field calculator expression to un-rotate streams:

``````from math import sin, cos
a=- math.pi/4
def RotateLine(x0,y0, shp):
part=shp.getPart(0)
ar=arcpy.Array()
for i in range(len(part)):
p=part.getObject(i)
x,y = p.X-x0, p.Y-y0
xN=cos(a)*x+sin(a)*y
yN=-sin(a)*x+cos(a)*y
pN=arcpy.Point(xN+x0,yN+y0)
lineRotated=arcpy.Polyline(ar)
return lineRotated
#------
RotateLine( !POINT_X!, !POINT_Y!, !Shape! )
``````

But I am sure you can find better tools. You'll need it to rotated you other shapes by 45 degrees at the very beginning.

More elegant solution possible for predefined outlets.

• Thank you very much for your answer. I tested your method. Streams are perfectly orthogonal. But tell me if I'm wrong, this method doesn't produce a flow direction raster with only 4 directions (Right, Down, Left and Up). Indeed, there is 8 directions in my direction raster. The orthogonal streams follow diagonals that are incised into the initial dem and this arbitrary network not reflect the appropriate network for the prevailing microtopography of the initial dem. – Raphaël Sep 3 '18 at 12:16
• What I would like to have is a flow direction raster for the East, South, West and North directions and this for the initial non-incised dem. – Raphaël Sep 3 '18 at 12:20
• Ok, I misunderstood objective. – FelixIP Sep 3 '18 at 18:40