Automating drawing of polygons (square) around number of points in QGIS?

In QGIS, how can I automate drawing a 100km x 100km square around a number of points, with the point being dead in the center?

I'd need to loop through all the points and create a polygon, but not sure what would be the automated way of doing so.

I was able to create buffers (circular) around the points, but now looking for a solution to convert those circles to squares -- something like the Envelope approach described here (but need it in QGIS): Creating square buffer around point feature using ArcGIS for Desktop?

• what is the arrangement of points, are they in a square? Oct 4 '12 at 3:23
• This depends strongly which area on the globe we are talking about. The polar and equatorial circumferences are different. And also: are your coordinates in degrees or cartesian? It should be fairly easy to calculate the bounding box with this information. Oct 4 '12 at 9:52
• The arrangement of points would be a square. 1km apart (or 500m apart). We're looking at North America only at this point, Canada specifically.
– NikG
Oct 4 '12 at 14:39

QGIS ships with OGR which has a method GetEnvelope():

# Returns the geometry's extent as a list (minx, maxx, miny, maxy)
<geom>.GetEnvelope()

You can easily use it from within your QGIS python console. If you want to convert those coordinates into a shape? Have a look at my answer to this question for some info on modules which will help you turning this list into a vector file. There you find also further details and some helpful links.

• Thanks LarsVegas! Can you script the entire process in QGIS (or outside of QGIS)?
– NikG
Oct 5 '12 at 21:54

You could use the mmqgis plugin for QGIS, which provides some more user-friendly implementations and interfaces of some QGIS functions. It adds an additional menu button next to "Web" and "Processing" from where you can choose "Create > Create Buffers" to get this interface: You get the option to choose in what units you want to measure the radius, how many edges you want - choose 4 for a square - and how the buffer should be rotated. At least in my case I also needed to rotate it by 45 degrees, otherwise it would have had kind of a rhombus-orientation. I did not try out the attribute option.

In QGIS 3 you can use Vector > Geoprocessing Tools > Buffer to do this. You will need to lower "Segment" to 4 and use "End cap style" of "Square". You control the size by specifying the "Distance" which should be half the side length you want. For your use case this would be 5000 meters. Note that you need to first reproject your points into a SRS which has units of meters.

You can use Geometry generator from the symbology of the layer. The make_square function would fit to your problem. The following figure shows how to create 1000 meter (supposing the distance unit is meter for the projection) square around each points. It will be drawn on the fly.

The original (point) and the effect of the geometry generator (point with square) on the canvas: