I have QGIS 2.18.16 installed. My problem is, how to calculate radius of an arc / curve feature (line)? The lines are originated from .dgn file, which I read with FME and wrote to PostGis DB. I have created primary keys etc, and the table is fully editable. I calculated lengths for the arcs successfully, but cant figure out how to calculate radius for these curves. This ( https://www.mathopenref.com/arcradius.html ) might give some idea on the math side, though I can't figure out how to use it in QGIS calculator. So I need to calculate the "R" for all the lines i have in the DB.

Bellow is an example. My data has Arcs / Curves on different table than "normal" polylines.

enter image description here

  • When I click on an arc with the Identify tool, one of the derived attributes listed is the "closest vertex radius." So there's no need to calculate the radius, you only need to figure out how to access this property in the field calculator. Or simply copy it from the identify tool.
    – csk
    Feb 8, 2018 at 18:26
  • You can also view the properties of a vertex when a layer is in edit mode by selecting vertices with the Node Tool. Then the vertex coordinates (x,y,r) display in the Vertex Editor panel.
    – csk
    Feb 8, 2018 at 18:30
  • Nice to know it is at least possible to see the radius via identify tool. With only few arcs copy-paste would be an option, but I plan to use this to the whole data I have, which has too many arc features to be done manually. :/
    – Sisuaski
    Feb 9, 2018 at 8:01
  • I googled around a bit, and it seems like not many people use circular string features in QGIS, so there's not a ready-made tool or function in the field calculator. You may need to define a custom Python function. If you want to go that route, add the pygis tag to your question.
    – csk
    Feb 9, 2018 at 17:31
  • How many vertexs do you have for feature? What do you see in the Vertex Editor when you click the Node Tool?
    – Marco
    Feb 12, 2018 at 12:01

4 Answers 4


Lightly tested formulas follow, so proceed with caution. But following along with an example here: https://www.mathopenref.com/arcradius.html enter image description here

If your circular arcs have a vertex at the middle point along the arc (which I am saying is x1, y1 in the figure), you could use it along with the start and end points to calculate the chord length "W" and the height "h" to get the radius "R" using the following formula:

enter image description here

and saying

enter image description here

W =

     ( $x_at(-1) - $x_at(0) )^2 +
     ( $y_at(-1) - $y_at(0) )^2


enter image description here

H =

    ( $x_at(1) - ( $x_at(-1) + $x_at(0) )/2 )^2
    + ( $y_at(1) - ( $y_at(-1) + $y_at(0) )/2 )^2

in your Expression Dialog of the Field Calculator you'd have this long equation for the radius calculation:

enter image description here

R =

    ( $x_at(1) - ($x_at(-1) + $x_at(0) )/2 )^2 
    + ( $y_at(1) - ($y_at(-1) + $y_at(0))/2 )^2
     ) /2
(   ( $x_at(-1) - $x_at(0) )^2 )  + 
    ( $y_at(-1) - $y_at(0) )^2 )  )
/ ( 8 * sqrt(
            ( ($x_at(1) - ($x_at(-1) + $x_at(0) )/2 )^2
            + ( $y_at(1) - ($y_at(-1) + $y_at(0) )/2 )^2
  • 1
    In LaTe X $$W= \sqrt {(x_{-1} - x_0)^2 +(y_{-1}-y_0)^2}$$ $$H = \sqrt { (x_1- \frac {(x_{-1}+x_0)} 2 )^2 + (y_1- \frac {(y_{-1}+y_0)} 2 )^2}$$ and $$R = \frac {\sqrt { (x_1- \frac {(x_{-1}+x_0)} 2 )^2 + (y_1- \frac {(y_{-1}+y_0)} 2 )^2}} {2} + \frac {(x_{-1} - x_0)^2 +(y_{-1}-y_0)^2} {8 \sqrt { (x_1- \frac {(x_{-1}+x_0)} 2 )^2 + (y_1- \frac {(y_{-1}+y_0)} 2 )^2}}$$
    – Marco
    Feb 17, 2018 at 16:22
  • Very good! I did not imagine how to access the vertexes. Is it possible in PostGIS?
    – Marco
    Feb 17, 2018 at 16:26
  • 1
    Marco, I believe it is possible to extract whatever vertice you are looking for. See the link here: postgis.net/docs/ST_PointN.html. Thank you for the most-excellent formula additions and edits.
    – cm1
    Feb 18, 2018 at 20:17
  • While waiting for developers to add a button to "easy calculate radius", this is most helpful answer I could hope for. Now I (and possibly others too) have at least some way to extract radius. :) I have not yet tested this, but I will in a few days when I have enough time. Thank you a lot for your help!
    – Sisuaski
    Feb 19, 2018 at 13:25

What about extracting the radius while extracting the data with FME? There you have the ArcPropertyExtractor transformer, which should give you the radius values in attributes ready to set in your PostGIS DB

  • That would be one possible way to proceed, a good way to handle the whole data. My problem is, there is not enough FME users in my organization and I need to make the process as easy as possible. That means, the whole process, including arcs, areas, lines etc., should be able to be done with Qgis. Ability to update Arc feature radius to new objects is what I need to be done with Qgis. Thank you for your reply though, I'll be updating radius attributes with FME for now, but hope there will be a way to do it with QGIS.
    – Sisuaski
    Feb 12, 2018 at 10:00

I wrote an octave/matlab script that calculates the radius of a polygon consisting of 5 or more vertices/points. Just put your polyline(s) in a shp-file and my script will add the radius as an attribute in the dbf-file. You need octave to run it.

You can find it here: Find radius of curve?


I was able to get the radius of all lines in the attributes table by adding a custom function.

from qgis.core import *
from qgis.gui import *

@qgsfunction(args='auto', group='Custom', referenced_columns=[])
def radius_function(startpoint, midpoint, endpoint, feature, parent):
    Calculate the radius of an arc line, using the inbuilt circleCenterRadius
    function and evaluations of the line end points and mid point.
    <h2>Example usage:</h2>
      <li>radius_function( start_point($geometry), $geometry, end_point($geometry) )</li>
    # # https://gis.stackexchange.com/questions/58079/finding-middle-point-midpoint-of-line-in-qgis
    startpoint_ = QgsPoint(startpoint.asPoint().x(), startpoint.asPoint().y()) # start of the line
    half_length = midpoint.length() # half length to the middle of the line
    midpoint_i = midpoint.interpolate(half_length /2) # calculate the middle of the line
    midpoint_ = QgsPoint(midpoint_i.asPoint().x(), midpoint_i.asPoint().y()) # Convert to Point
    endpoint_ = QgsPoint(endpoint.asPoint().x(), endpoint.asPoint().y()) # end point of the line
    # circleCenterRadius returns tuple (radius, center x coordinate, center y coordinate)
    radius_, center_x, center_y = QgsGeometryUtils.circleCenterRadius(startpoint_, midpoint_, endpoint_)     
    return float(radius_)

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.