A Processing model for Tanaka contours
If you follow my blog, you’ve most certainly seen the post How to create illuminated contours, Tanaka-style from earlier this year. As Victor Olaya noted correctly in the comments, the workflow to create this effect lends itself perfectly to being automated with a Processing model.
The model needs only two inputs: the digital elevation model raster and the interval at which we want the contours to be created:
The model steps are straightforward: the contours are generated and split into short segments before the segment orientation is computed using the following code in the Advanced Python Field Calculator:
p1 = $geom.asPolyline() p2 = $geom.asPolyline()[-1] a = p1.azimuth(p2) if a < 0: a += 360 value = a
You can find the finished model on Github. Happy QGISing!
Can we use qgis processing `Model` in qgis `Plugin` as such or it will require significant changes
Processing scripts and models can be called from python using processing.runalg(…). No changes should be required.