Using QGIS with GRASS I have found a route through r.drain but it has many sharp curve. the maximum radius of curve allowed to me is 176m. Is there any to reduce the curve sharpness to 176m or at least to find the radius of a curve?

• Measured over how long distance / number of vertices?
– BERA
Dec 8, 2021 at 14:42

As a general hint, you can search functionality in the GRASS GIS documentation with g.search.modules.

To your question: maybe the "sinuous: line sinuousity, calculated as line length / distance between end points" functionality of v.to.db may help to approximate this value.

Overall, to reduce the curve sharpness, you can generalize the vector lines with v.generalize.

I've written a small algoritm in octave/matlab to calculate the curve radius from polylines in a shape-file.

Here you go:

``````clc
clear all

##Run in octave version 6.4.0

## Calculates curve radius in meters. You need to save your shp in a meter based
## coordinate system.

##By Gustav Grundfelt (c) 2021

##Permission is hereby granted, free of charge, to any person obtaining a copy of
##this software and associated documentation files (the "Software"), to deal in
##the Software without restriction, including without limitation the rights to use,
##copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
##Software, and to permit persons to whom the Software is furnished to do so,
##subject to the following conditions:
##
##The above copyright notice and this permission notice shall be included in all
##copies or substantial portions of the Software.
##
##THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
##IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
##FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
##AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
##LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
##FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
##IN THE SOFTWARE.

%input file path

%output file path

for n_poly=1:1:length(outstruct)
n_point = length(outstruct(n_poly).X);
r_mean=0; counter=0;
r_mean_w=0; counter_W=0;

x0=outstruct(n_poly).X(1);
xN=outstruct(n_poly).X(n_point);
y0=outstruct(n_poly).Y(1);
yN=outstruct(n_poly).Y(n_point);

Htop=0;

W_seg=sqrt((xN-x0)^2+(yN-y0)^2);

%polylines must have minimum 5 points else they are omitted
if n_point > 4
for i=2:n_point-1
x=outstruct(n_poly).X;
y=outstruct(n_poly).Y;

%https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
d=abs((xN-x0)*(y0-y(i))-(x0-x(i))*(yN-y0))/W_seg;

if d > Htop;
Htop=d;
endif

end

r_calc = Htop/2+W_seg^2/(8*Htop)