Sophisticated generation and calculation of Vector entities from Raster Data?

• 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?

• What does "DN" mean in criterion (1)? What additional constraints are there on these "vector entities"? Without some severe constraints, this problem is ill-defined. Could you explain the purpose of this intended analysis? What problem is it intended to solve? – whuber May 12 '15 at 17:18
• DN = Digital Number it's the value of the altitude.The vector entities are the result of the process, the purpose is to generate an shp wish contains 2 vector entities wish repond to the creteria above – elmo May 12 '15 at 22:40