3

I generated a bounding box by calculating the extent of each feature using "Polygon from layer extent..." tool located in "Vector/Research Tools" which works great but I lost the fields, especially the name of each polygon. Does anyone know how to keep the fields in the process?

4

Use another tool through the menu Processing - Toolbox - QGIS geoalgorithms -Vector geometry tools - Bounding boxes. The tools looks almost the same than the one you used but instead of computing some new statistical attributes this tool just copies all the attributes from the source layer.

enter image description here

  • I now think this is the answer, but this tool is only in QGIS version 2.18.15... missing from QGIS version 2.14.21 – Steeve Brissette Jan 13 '18 at 1:57
2

After generating a bounding box from the polygon layer, you can use Join attributes by location to copy the information of the original polygon to the newly created polygon extent. Go to Processing toolbox -> QGIS geoalgorithms -> Join attributes by location.

In the following example, I have a polygon (cyan color) and I generated a polygon extent (light brown color), and the attributes are shown in the image below:

enter image description here

Using Join attributes by location:

enter image description here

  • Target polygon: Polygon extent
  • Join vector layer: The original
  • polygon Geometric predicate: intersects

Here is the output:

enter image description here

  • I wonder how well it works when bounding boxes intersect many polygons as happens with adjacent polygons. – user30184 Jan 11 '18 at 5:48
  • @user30184 in this case, it is better to use within located under polygon Geometric predicate rather than intersect, and since the bounding should cover completely the the target polygon, using within can solve the problem. – ahmadhanb Jan 11 '18 at 5:53
  • That's better but it is still possible to have other polygons which are within the same bounding box. In your example image there is plenty of room in every corner. – user30184 Jan 11 '18 at 7:16
  • @user30184 it is possible, but that depends on how the polygons are distributed. The solution I presented may solve the problem, but the asker may encounter some troubles if there are many polygons fitted within the same bounding box which can be adjusted manually in this case. – ahmadhanb Jan 11 '18 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.