How to select a mesh peaks and troughs I have this mesh:



With a python script, I'd like to select the peak and / or the hole. I put them together because it looks like the solution is the same...
More exactly I'm looking for a way to tell those features apart from the rest of the mesh...
Blue selected edges show the (hypothetical) boundaries. Feels like it's something related to curvature, but not sure...

EDIT: result by selecting edges at angles (50°):



faces selection (vector (0,0,1)):



(I don't understand this)
EDIT: now I got it. It requires a more precisely oriented vector to tell faces by angles. Gotta look for this better.
Face normals, Edge angles, and link edges count.

In your screenshot the peaks and troughs are extrusions which have a vertex edge count of 5, which is a simple test.

Can also look at the signed edge angle to find peaks and troughs. I've used 50 degrees.

And also look at face normals vs an up vector. (A simple z axis to test)

Test script run in edit mode.

import bpy
import bmesh
from math import radians
from mathutils import Vector

ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)

up = Vector((0, 0, 1))

#  because its an extrusion select on link edges 
for v in bm.verts:
    v.select = len(v.link_edges) == 5

test_angle = radians(50)
# select edges on face angle
for e in bm.edges:
    if e.is_boundary:
        continue
    # hills 
    e.select = ( e.calc_face_angle_signed() &gt; test_angle    
    # troughs
    or e.calc_face_angle_signed() &lt; test_angle

for f in bm.faces:
    f.select =  f.normal.angle(up) &gt; test_angle


Some combination of any or all of the tests above should cover most cases.