3

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?

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

2 Answers 2

2

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.

0

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.

%load mapping toolbox
pkg load mapping

%input file path
filepath="C:\\Temp\\Kurvradier_50m";

%output file path
savepath="C:\\Temp\\Kurvradier_GG_50m";

%read shp
outstruct=shaperead(filepath)


limit_radius=10000;


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
       
    %Metod % segment radius
    %formula: https://gis.stackexchange.com/questions/270749/qgis-calculate-radius-of-an-arc-to-attributes?noredirect=1#comment432298_270749
    r_calc = Htop/2+W_seg^2/(8*Htop)
    
    outstruct(n_poly).Radius=int32(limit_radius);
    
    if r_calc < limit_radius
      outstruct(n_poly).Radius=int32(r_calc);   
    endif
   else
     outstruct(n_poly).Radius=NaN;
   endif
end

%write shp file
shapewrite(outstruct,savepath)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.