13

I have some polygon-shapes in qgis-1.7.0 and want to ensure that every polygon is a rectangle. See image below.

enter image description here

Is there any way I can do this in QGIS (or any other f/oss)? Or how can I improve my polygon-drawing to make sure for example that every building consists of rectangles (all angels = 90°)?

Any hints appreciated! Thanks!

7
  • Ignore my close flag. It is a different question.
    – Nathan W
    Commented Dec 28, 2012 at 11:54
  • In theory it should be pretty easy to write something to do this. Loop each point in the odd shape, checking the angle to the next point from the current one if it's not 90 then calculate the new point and adjust the point. Now someone just needs to write the code :)
    – Nathan W
    Commented Dec 28, 2012 at 13:17
  • read this answer for orthogonal digitizing.
    – urcm
    Commented Dec 28, 2012 at 14:02
  • 2
    @Nathan It's nowhere as easy as that in general, because each time you change a vertex location you create distortions elsewhere. Even when fixing near-rectangles (as opposed to more complicated polygons) you can wind up producing new features that are clearly not very good approximations to the original ones. One problem is that there is not a unique way to calculate a new point at a bad vertex. See forums.esri.com/Thread.asp?c=93&f=987&t=303128#948330 for a discussion and pseudocode. I tested that approach (using Excel, of all things!) and found that it tends to work well.
    – whuber
    Commented Dec 28, 2012 at 16:23
  • 1
    @Under I cannot find it either. A closely related one (where I wrote a comment, not an answer) is Finding Polygons Without Right Angles. In my search I also uncovered How to Create Polygons with Straight Lines and Right Angles in QGIS as well as a duplicate (which I have just closed and merged).
    – whuber
    Commented Dec 31, 2012 at 14:26

4 Answers 4

4

There is a QGIS Tool called Oriented minimum bounding box. You can find it under Processing > QGIS geoalgorithms > Vector general tools. I'm using QGIS 2.18.

Maybe this comes close to what you want to achieve.

enter image description here

1
  • Cool, this is very close to what I have been looking for!
    – q9f
    Commented Jan 18, 2018 at 15:53
3

This is an old question, but in QGIS 3.X you can use the geoprocessing tool "Orthogonalize." It allows you to set tolerances for angles to be converted to right angles or straight lines, so it's a more customizable and precise solution than the minimum bounding box, which is always and necessarily going to be larger than the input polygons.

2

You can fix it with bounding box area of all polygons. The name of function is Polygon from layer extent.

enter image description here

Select your layer and mark the option calculate extent for each feature separately:

enter image description here

All original polygons are present in the same layer, not separately. QGIS will calculate the bounding box area for all entities:

enter image description here

QGIS Rocks! Hugs from Brazil!

Jorge Santos

1
  • 1
    The answer does not take into account the rotation of the polygons.
    – GreyHippo
    Commented Sep 26, 2016 at 15:04
0

This is indeed an old question but as QGIS evolve (as answering latest is 3.12.2) new answer may be in order...

For the first part of the question you may try the Rectanglify plugin that claim to do exactly that (I didn't try it).

For the second part of the question (how can I improve my polygon-drawing to make sure that every building consists of rectangles) you may use the advanced digitizing panel that will help you to get consistant length and angle, or use one of the add rectangle tool from the shape digitizing toolbar or use a plugin like AcheoCAD, QAD, RectangleCreator (I didn't use any of these but all claim to be able to create rectangle)...

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.