In QGIS 3.28.10 I need to draw a perfect square (polygon) in a shapefile. I know each side is 20 meters.
-
I'm using QGIS 3.28.10– AgosCommented Jul 30 at 13:57
-
Have you read that : docs.qgis.org/testing/en/docs/user_manual/working_with_vector/… ?– J.RCommented Jul 30 at 14:13
-
There are very few perfect squares in nature, or GIS -- The Earth is a geoid, after all. You may need to downsample your definition of perfection.– VinceCommented Jul 30 at 19:32
-
3There are very few perfect things in life in general– AgosCommented Jul 31 at 13:31
3 Answers
You can use the "Advanced digitizing panel".
Extract from the manual: The Advanced Digitizing panel can be opened either with a right-click on the toolbar, from the View ► Panels ► menu or by pressing Ctrl+4.
The panel looks like this:
Then:
- Enable editing on the layer
- Use the standard "Add polygon feature" to start adding the square
- In the "Advanced digitizing" panel, click the button at the top left ("Enable advanced digitizing").
- On the map, click where you want to put the first point of the square
- In the "Advanced digitizing" panel, in the top field (d) fill out the desired distance: 20 in your example. To the right of that field, enable the 2 "lock" buttons so the tool remembers this distance also for all following sides of the square.
- In the "Advanced digitizing" panel, in the second field (a) fill out the desired angle: 90 for a rectangle/square. To the right of that field, enable the 2 "lock" buttons so the tool remembers this distance also for all following sides of the square.
- In the map, add the 3 extra points of the square. The settings chosen above will make sure the angles are square and the sides are all 20 long.
- Right-click to close the square.
Step 3 will be remembered if you add more squares.
In addition, if you want to draw multiple squares of the same size in the same neighbourhood, you can consider using the copy and move features tool on the "advanced digitizing" toolbar to make the copies.
-
2Note that the Advanced Digitizing panel only work with layer in a projected CRS– J.RCommented Jul 30 at 15:25
-
1
- Place a point at each square’s center location.
- Buffer each point by 1/2 of the square side length, i.e. 10 m.
- Run the tool: Processing > Vector Geometry > Bounding Boxes, using the buffer layer as input.
- Voila!
If you need to draw many squares this can be an option:
- Create a point layer, I'm using a temporary scratch layer
- Create a virtual layer which buffers the points and envelope the buffers, to create the squares:
Change 200.0 to the the half the square size you want (10), and My point layer to the name of your point layer. Execute the query and "Load as new Layer"
select row_number() over() as id, st_envelope(st_buffer(geometry, 200.0, 16)) as geometry
from "My point layer"