[Qgis-user] line in dem from max to min

Micha Silver Micha at arava.co.il
Tue Jul 7 23:21:15 PDT 2015


v.botz wrote
> Hi,
> 
> i have some geometrys (multipolygon) and a dem (digital elevation model)
> -> I need a line from the max value to the lowest value of the dem, for
> every multipolygon
> 
> is qgis a tool i could use - or do i need PostGIS ?
> 
> how could i realize this problem ??
> 
> any ideas?  THANKS

I can see a possible solution using GRASS. It's a bit complicated, but
*should* work.

Starting with the vector module v.rast.stats you can add to your polygons
the minimum and maximum elevation values for each polygon as new attribute
columns.
Now you need to loop thru all the polygons (using your favorite scripting
language). The v.db.select module will give a list of cat values and the
min/max from above. Loop thru that list and for each cat value create a
raster mask based on that polygon: something like 
r.mask raster=MASK vector=<polygons> cats=<the current cat value>. 
Then, with that mask in place, use an r.mapcalc expression to create a new
raster with only the min/max values. Such as: 
r.mapcalc --o "min_max = if(dem>=max OR dem<=min, dem, null() )"

All other raster cells will be NULL. Now convert this new raster to a point
vector. It will have only two points, the min and max elevation within the
current polygon. And using those two points, create your line.
Finally remove the mask and loop to the next...
 
HTH,
Micha



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/line-in-dem-from-max-to-min-tp5214619p5214779.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.



More information about the Qgis-user mailing list