Detecting Peaks and Summits

Comparing two morphometric peak classifications

Detecting fuzzy peak membership using morphometry

The example below mimics LandSerf's 'Fuzzy Feature Classification' by identifying peak features over a range of scales. It has slightly greater flexibility than LandSerf's menu option in that both the minimum and maximum window sizes can be specified. It would also be possible to modify this code in line 28 so that a window sizes were selected in a non linear way (e.g. by doubling the window size on each iteration through the loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Script to find fuzzy feature memberships.
version(1.0); 

# Change the directory below to correspond to your file location.
baseDir = "c:/Program Files/LandSerf/data/landscriptExamples/";

# Change the values below to define the feature to explore
# and the scale range over which that feature is to be extracted.
featureName    = "peak";
decayExp    = 0.0;
slopeTol    = 20;
curveTol    = 0.2;
minWinSize    = 5;
maxWinSize    = 19;

dem = open(baseDir & "dem.srf"); 
fuzzyFeature = new(dem);  
winSize = minWinSize; 
numScales = 0; 
featureID = getFeatureID(featureName);  

while (winSize <= maxWinSize); 
{  
    echo("Processing with "&winSize&"x"&winSize&" window.");
    numScales = numScales+1;
    features = surfparam(dem_,"feature",winSize,decayExp,slopeTol,curveTol); 
    fuzzyFeature = ifelse(features==featureID,fuzzyFeature+1,fuzzyFeature);
    winSize = winSize + 2; 
} 

fuzzyFeature = fuzzyFeature/numScales;

# Add metadata and save
edit(fuzzyFeature,"title","Fuzzy "&featureName&" membership");
if (featureID == 1); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 0 0 0");}
if (featureID == 2); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 0 0 200");}
if (featureID == 3); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 0 150 0");}
if (featureID == 4); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 250 250 0");}
if (featureID == 5); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 200 0 0");}
if (featureID == 6); { colouredit(fuzzyFeature,"rules","0 255 255 255, 1 200 200 200");}

save(fuzzyFeature,baseDir&"fuzzy"&featureName&".srf"); 


# --------
# Function to report the numeric feature id corresponding to the given feature.
function getFeatureID(featName)
{
    if (compare(featName,"pit") == 0);         {return 1;}
    if (compare(featName,"channel") == 0);    {return 2;}
    if (compare(featName,"pass") == 0);        {return 3;}
    if (compare(featName,"ridge") == 0);    {return 4;}
    if (compare(featName,"peak") == 0);        {return 5;}
    if (compare(featName,"planar") == 0);    {return 6;}

    echo("Unknown feature type '"&featName&"'. Assuming 'planar'.");
    return 6;
}

Detecting peaks using relative drop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Identifies peaks and summits on a DEM
version(1.0);

# Change the directory below to correspond to your file location.
baseDir = "c:/Program Files/LandSerf/data/landscriptExamples/";

# Open raster DEM.
dem = open(baseDir&"dem.srf");

# Perform the peak identification.
fuzzyPeaks = new(dem);
summits = newvector(0,0,0,0);
hierarchy = new(dem);
peaks = peakclass(dem,50,"null",fuzzyPeaks,summits,hierarchy);

# Save the new peak and summit maps.
save(peaks,baseDir&"peaks.srf");
save(fuzzyPeaks,baseDir&"fuzzyPeaks.srf");
save(summits,baseDir&"summits.vec");
save(hierarchy,baseDir&"peakHierarchy.srf");