2

I just created a Bounding Boxes layer using a layer of oddly shaped polygons as the input.

The Bounding Boxes layer has a bunch of symmetrical rectangular polygons on it now, all oriented parallel with the X axis.

I need to buffer all of these rectangular polygons now. When you buffer a line using the buffer tool, and select Flat end style, the tool doesn't buffer the ends of the line.

The buffer result is flush with the end of the input line.

I need to do the same sort of thing with these rectangular polygons.

I want the buffer only to apply to the North and South sides of the rectangular polygons and not the East and West sides.

So the rectangular polygons will get taller when the buffer is applied, but not wider.

Is there a tool that will do this?

When I use the buffer tool it always applies the buffer to all sides of the polygons no matter what the settings are.

3 Answers 3

3

QGIS 3.0/3.2

  1. Start Geometry by expression tool. (in Processing Toolbox | Vector geometry)
  2. Give an Geometry expression as below. Click on Run in background.

QGIS 2.18

  1. Make a copy (duplicate) layer (as following process will modify current geometry)
  2. Open attribute table and start the Field calculator
  3. Select Update existing field option and <geometry>
  4. Give expression below. Click on OK.

Expression is:

bounds(make_line(make_point(x_min($geometry), y_min($geometry)- 1000), 
                 make_point(x_max($geometry), y_max($geometry)+ 1000)))

The above example expands the bounding box 1000m to north and south respectively.

0
2

You can create a virtual layer that expands the bounding box of the original polygon (you don't need the intermediate BB layer).

Let's note that the function ST_EXPAND can't be used here, as the currently supported version expands in all direction. Should you have access to PostGIS, this function could be used, specifying to expand only in the Y direction.

So, go to the menu layer / add layer / add-edit virtual layer and put the following query. It assumes your source layer is named a and has an id field. It is important to keep the content of st_geomFromText on a single line. So, this function takes each geometry from the source layer, then create a new polygon minX-minY/maxX-maxY and expands in the Y direction (+-1 "map unit" in this example)

select  id, 
        st_geomfromtext('POLYGON((' || st_minx(geometry) || ' '  || (st_maxy(geometry)+1) || ',' || st_maxx(geometry) || ' '  || (st_maxy(geometry)+1) || ',' || st_maxx(geometry) || ' '  || (st_miny(geometry)-1) || ',' || st_minx(geometry) || ' '  || (st_miny(geometry)-1) || ',' || st_minx(geometry) ||  ' '  || (st_maxy(geometry)+1) || '))') as geometry
from a
1
  • Thank you JGH This works and gives the desired results, but Kazuhito's solution is a simpler expression for me to understand. I am in QGIS3.0 so I don't need to worry about the duplicate layer issue.
    – bkg73123
    Jul 5, 2018 at 19:21
-1

There is already a function

st_envelope(geometry)
1
  • 1
    The bounding box mentioned in the question is already an envelope. Creating envelope doesn't mean buffering in GIS. Oct 28, 2020 at 11:49

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.