How do you split a circle polygon into equal sectors that are 5 degrees in width in QGIS? I have a shapefile from a boundary of a field and want to break it into sectors.
-
4By definition, a quadrant is 1/4 of a circle. I wonder if you meant quadrat, which Wikipedia defines as "a frame, traditionally square, used in ecology and geography to isolate a standard unit of area for study of the distribution of an item over a large area." If so, you should keep in mind that, "modern quadrats can for example be rectangular, circular, or irregular." Please edit your question to clarify how you want to divide up your circle. An image showing the desired output would be helpful.– cskCommented Oct 2, 2018 at 17:25
-
Maybe OP wants Sectors– Devdatta TengsheCommented Oct 3, 2018 at 5:20
-
seems that wedge buffer qgis native algorithm is what you are looking for.You can find it in Processing tool box of the 3.x version.– Luigi PirelliCommented Oct 3, 2018 at 15:54
-
1Please, do not forget about "What should I do when someone answers my question?"– Taras ♦Commented Dec 16, 2023 at 7:55
3 Answers
5 degrees is 1/72 of a circle.
- Use the "Minimum enclosing circles" tool to create a circle with 72 segments.
- Use "Extract Vertices" to turn this circle into 72 points in a layer called Ring.
- Create a layer with a single point at the centre (actually you could do this with the "Centroid" of the circles) called Hub
- Add an attribute to Ring called
d
with the value 1 for all points. - Add an attribute to Hub called
d
with the value 1. - Use "Join by lines (hub lines)" with the Hub as the hub and Ring as the spokes, use
d
as the field in both cases so you match each ring point to the centre. Call this layer Spokes.
- Create a Line version of the circle polygon using "Polygons to Lines" called Rim
- Use "Merge Vector Layers" to merge the Spokes with the Rim in a new layer called Wheel.
- Use "Polygonize" on Wheel to build 72 polygons of five degree angle in a new layer called Wedges:
This can all be wrapped into a single processing stream that looks like this:
File available in a gitlab snippet: https://gitlab.com/snippets/1759618
-
-
I suppose you could create 72 points at the centre location and set an angle attribute on each one... Commented Oct 3, 2018 at 15:57
-
@Spacedman: Please make the file available, would be nice for learning how to do automation in qgis. thx– KurtCommented Oct 3, 2018 at 20:16
-
Have done, should be public at the gitlab snippet link in edit. Commented Oct 3, 2018 at 21:01
The other answer covers the topic well, I am providing an alternative solution.
Since QGIS 3.2 (see the Changelog), it has a native tool called "Create wedge buffers", which I suggest using for this case. The tool inputs are a center point, an azimuth, a width, an inner radius, and an outer radius. In this case, the inner radius is zero, and the outer radius is 9. The center point is “O”, also known. The width is 5 degrees.
The azimuth of each wedge generated should be displaced exactly 5 degrees from the previous one, and a total of 360/5 = 72 wedges should be generated.
The azimuth of each wedge is given by the expression width/2 + width*k, in which k=1,2,…n, and n is the total number of wedges. I have a larger explanation about this expression in a blog post.
One of the easiest ways to generate these wedges is by using batch process functionality on the "Create wedge buffers" tool. Add 72 rows. Fill the width (5 degrees) and choose the “Fill Down“ option. For the azimuth, choose the option “Calculate by Expression“ and use the following expression:
@WIDTH/2 + @WIDTH * @row_number
Click OK and the azimuth values should be filled. Fill in the other fields and Run.
Result:
I have also worked on the automatization of the wedge tool to do this and other tasks using PyQGIS, for which you can find more information and code snippets in my blog: https://www.luisalucchese.com/post/qgis-the-wedge-tool/
Use the following expression with Geometry Generator or Geometry by Expression (see here for details) on a point layer that contains the center of the circle:
collect_geometries(
array_foreach(
generate_series(0, 355, 5),
wedge_buffer (
$geometry,
2.5+@element*5,
5,
500 -- size (radius) of the circle
)
)
)