# Extracting very small local ridges out of DEM

I have a DEM with small pits (one pit is approximately 5-10 cm wide, here shown as Hillshade).

I want to extract the ridges of these pits to have polygons out of each pit (like this where I did it manually)

The main problem is, that the for one pit the ridge on the right side f.e. is much higher than the one at the left side, because the overall of the wall is quite curved and seen from the front then the ridge on the left could have the same value than the "deepest" point of the pit. I tried to visualize what I mean - that is the wall drawn if you see it from the top.

So, on the one hand I tried to calculate the bigger mean of the whole area and then to nivellate the whole DEM to get it like in the picture above on the right side. However the problem is that my whole area is not only going convex but also concave and in all possible directions so that it is not possible to nivellate it properly.

The solution I reached up to now is, that I calculate the curvature and then thinning the areas. However, the thinning resolved on lines being not properly on the ridges and some weird polygons that do not match at all - see below. I also tried it with Topographic Position Index, however, the ridges are not marked well enough in many cases to close the pits into single polygons.

Does someone have another idea how to be able to extract those ridges as good as possible?

I am open to all kinds of software and solutions: ArcGIS, QGIS, R, Python,...

• Of course: drive.google.com/open?id=16vEx1_W8xvxVOFEEFNUkt4pxNyOyTtPP It is really big so I clipped it to a smaller area and it has only a local coordinate system, thus no spatial reference Mar 7 '20 at 20:45
• I work with 1m and 2m DTMs and I've been 'de-trending' them to 'flatten' underlying terrain. The scales you an I are working with are very different, but I wonder if 'de-trending' would work for your data? I don't have a clue about what settings you'd have to use, but the method is explained (in Clause 10.3): here: bajr.org/BAJRGuides/42_QGIS_StarterGuide/42_BAJR_Guide_QGIS.pdf Just a thought. Mar 8 '20 at 13:11

Not sure this can be fully automated, but workflow below will give you very good estimation of ridges:

``````arcpy.Curvature_3d(in_raster="DEM_clipped.tif", out_curvature_raster="C:/SCRATCH/CURVA", z_factor="1", out_profile_curve_raster="", out_plan_curve_raster="")
arcpy.gp.RasterCalculator_sa('("CURVA" - "CURVA".minimum)/1000000', "C:/SCRATCH/FLATTENED")
arcpy.gp.Fill_sa("FLATTENED", "C:/SCRATCH/FILLED", "")
arcpy.gp.RasterCalculator_sa('Con("FILLED" > "FLATTENED","FILLED" - "FLATTENED")', "C:/SCRATCH/DEPTH")
arcpy.gp.FocalStatistics_sa("DEPTH", "C:/SCRATCH/FS", "Rectangle 15 15 CELL", "MAXIMUM", "DATA")
arcpy.gp.RasterCalculator_sa('Con("DEPTH" >= "FS",1)', "C:/SCRATCH/TWO")
arcpy.gp.RasterCalculator_sa('Con(IsNull("TWO"),"FLATTENED")', "C:/SCRATCH/HOLES")
arcpy.gp.Fill_sa("HOLES", "C:/SCRATCH/F_HOLES", "")
arcpy.gp.FlowDirection_sa("F_HOLES", "C:/SCRATCH/H_FDIR", "NORMAL", "")
arcpy.gp.RegionGroup_sa("TWO", "C:/SCRATCH/RGP", "FOUR", "WITHIN", "NO_LINK", "")
arcpy.gp.Watershed_sa("H_FDIR", "RGP", "C:/SCRATCH/W4", "VALUE")
``````

In words:

• use curvature to flatten DEM
• find 'depth' of water over flatten DEM
• find local maximums of depth and use them as sinks for watershed analysis

Picture below shows semi-transparent watersheds over original DEM hillshade:

• Thanks, exactly what I was looking for! Mar 9 '20 at 7:28
• Interesting surface. Melting ice? Do you mind telling what is it please? Mar 11 '20 at 4:22
• Almost - some icebergs do have those forms as well yes, it is generated through waterflow, however, in this case it's limestone. See also: cambridge.org/core/journals/journal-of-fluid-mechanics/article/… for a short description. Mar 11 '20 at 13:12