Wednesday, 15 March 2017

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?



Answer



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


# Returns the geometry's extent as a list (minx, maxx, miny, maxy)
.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.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...