8

I received an answer to Changing Points into Hexagon-Polygons using QGIS, which enabled me to change the point to polygons using the "Rectangles, Ovals, Diamonds" tool, which I used circles.

My client wants the shape to be a hexagon based on the width field in the data. The data field has a meter amount as in 5 for 5 meters.

Is there any way to make the circle a hexagon?

1

2 Answers 2

19

Yes, try to use the make_regular_polygon() via the "Geometry by expression" from the Processing Toolbox (Ctrl+Alt+T).

Let's assume there is a layer 'Polygon' with circles, see image below.

input violet points are just the base for circles

In the "Geometry by expression" window use a formula for creating hexagons in 'Geometry expression' field accordingly for

tool_window

inscribed

with this expression

make_regular_polygon(centroid($geometry), point_on_surface(boundary($geometry)), 6, 0)

and get the output inscribed

circumscribed

with this expression

make_regular_polygon(centroid($geometry), point_on_surface(boundary($geometry)), 6, 1)

and get the output circumscribed

10

You can get hexagons from circles using Centroids and Rectangles, Ovals, Diamonds tools, consecutively.

"Centroids" tool generates centroids, of course. New "Centroids" layer has all columns of "Circles" layer. Then, you can generate hexagons based on Width field using "Rectangles, Ovals, Diamonds" tool as in the image.

  1. Shape: Oval
  2. Width/Height: Click "Data defined override" button > Field > Width
  3. Segments: 6

enter image description here

I assume your data uses a projected coordinate system. In case of geographic, this method does not work.

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.