The first image below is shown a raster wish represents the altitude value. I created this raster by applying this process, bu using this process we can manually select an upper and lower area (so 2 vector entities) under some constraints like:
1 The difference of altitude between the two entities is upper than 200 m 2 The maximum distance between the tow entities is lower than 1000 m 3 The area of each entities is : 1.5 ha <area< 2.5

- The second image below is shown a manuell detection of the upper and lower area wish is too hard to perfom.

- My purpose is to automatically generate vector entities where every proposition (two entities) is saved on one vector layer with the ID, area and the distance between two entities so if it's generate 1000 propositions (1000 upper and 1000 lower) my result will be 1000 shp.
- I can control the form of area using the Miller index using this formula:
C=(4π*A)/P^2
where A is the area and P is the perimeter
C is equal to 1 if the form is circular and 0.75 if the form is square
So I can define a threshold to delete all proposition wish have a Miller index mower than 0.6 for example
Is there any way to solve this problem using GRASS commands or Python?