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!

underdark
  • 84,148
  • 21
  • 231
  • 413
q9f
  • 2,176
  • 5
  • 33
  • 53
  • Ignore my close flag. It is a different question. – Nathan W Dec 28 '12 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 Dec 28 '12 at 13:17
  • read this answer for orthogonal digitizing. – urcm Dec 28 '12 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 http://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 Dec 28 '12 at 16:23
  • @whuber Wasn't there a similar question a few months ago? I cannot seem to find it. I think you answered it back then. – underdark Dec 31 '12 at 00:10
  • 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 Dec 31 '12 at 14:26
  • When did that question get closed? This question is about post-processing of existing polygons, not about creating simple rectangels. – q9f May 26 '13 at 09:22

4 Answers4

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

Stefan
  • 4,414
  • 1
  • 33
  • 66
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.

LAT
  • 559
  • 1
  • 5
  • 20
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

Jorge Santos
  • 545
  • 3
  • 13
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)...

J.R
  • 16,090
  • 1
  • 19
  • 52