While measuring an angle in QGIS using measure angle tool, it is showing as 0 to 180 degree for clockwise direction and -1 to -179 for anticlockwise. What I need is, interior angle between vertices of irregular polygon. How should I calculate in QGIS?
[GIS] How to measure angle in QGIS
anglesqgis
Related Solutions
QGIS >= 2.18
New function (after this question was posted) azimuth()
has become available, and made this calculation easier.
If we have two point layers, one of which is your samples layer and the other is the specific third point. In the example below they correspond to:
TargetPoints_4326
: sample points. Only unique id ("id"
) field is required. I have only three ("id"=1,2,3) pink-colored points in this example.ObsPoints_4326
: your observation points to measure the angle. I have three overlapping points (green color). This layer has to have "EPSG_code" field to define the CRS you want to work, along with "Start" and "End" fields as pointers to the"id"
field of the sample points layer.
Then open the attribute table of your observation points layer (e.g. ObsPoints_4326
) and create a new field ("angle") with following expression:
degrees(
azimuth(transform($geometry,'EPSG:4326',"EPSG_code"),
transform(geometry(get_feature('TargetPoints_4326', 'id', "Start")),
'EPSG:4326',"EPSG_code"))
-azimuth(transform($geometry,'EPSG:4326',"EPSG_code"),
transform(geometry(get_feature('TargetPoints_4326', 'id', "End")),
'EPSG:4326',"EPSG_code"))
)
Output ("angle") field is measured anti-clockwise (e.g. first row on the attached picture shows angle= 27.185). If you want clockwise- measurement, please edit the above expression to switch "Start" and "End".
Note: This example used Lambert Conformal Conic (EPSG:3034) which will be good if your points are spread across large area in Europe. If your study area is local, UTM would do.
Best Answer
http://anitagraser.com/2015/05/24/how-to-create-illuminated-contours-tanaka-style/ contains some way to do this:
First you split the lines/polygons into their atomic segments with v.split.
Then you calculate the azimuth for each of those features, see eg How to add Direction and Distance to attribute table? for the formula.
I don't know a better way but maybe there is.