5

I'm creating a layer with single sided buffers based on a line layer as virtual layer in QGIS with the following query:

SELECT
 id,
 ST_SingleSidedBuffer(layer.geometry, layer.buffer_dist, layer.side) 
FROM
 layer;

The buffer distance and the buffer side for each feature ist stored in the attribute table.

I would like to the set the join style to 'MITRE'. I found that there should be a way to set the option like this (https://www.gaia-gis.it/fossil/libspatialite/wiki?name=BufferOptions):

SELECT BufferOptions_SetJoinStyle('MITRE');

Unfortunately I get the following error message:

Query preparation error on PRAGMA table_info(_tview): no such function: BufferOptions_SetJoinStyle

Hence my question: Is there a way to set the buffer options globally in the QGIS project? Or is there a way to set the buffer options within the query?

Taras
35.8k5 gold badges77 silver badges151 bronze badges
asked Nov 9, 2021 at 8:27
1
  • 3
    As stated in your link, this feature set is available with SpatiaLite 5.0 and above. I believe even at version 3.20 QGIS is built with SpatiaLite 4.3.0a by default, so you do not have access to that feature set within the native QGIS environment. Commented Nov 9, 2021 at 9:17

1 Answer 1

1

As it does not seem to be possible right now using a virtual layer (as stated in the comment by @geozelot), you might want to use another method to achieve the same result. You can use QGIS expressions with Geometry generator (for visualization only) or Menu processing / Toolbox / [Geometry by expression]2 to create actual geometries (see here for details).

Use the function single_sided_buffer, it has the following syntax:

single_sided_buffer(geometry,distance[,segments=8][,join=1][,miter_limit=2.0])

Help says:

join - join style for corners, where 1 = round, 2 = miter and 3 = bevel

The whole expression thus looks something like (change the fieldnames "buffer_dist" and buffer_side):

single_sided_buffer(
 $geometry, 
 "buffer_dist" * "buffer_side",
 join:=2
)

The expression, here with Geometry genrator - initial line in red, buffers in blue: enter image description here

answered Nov 9, 2021 at 11:23
4
  • This topic is about a Virtual Layer, not Geometry by expression, Geometry generator etc. :) Commented Nov 9, 2021 at 12:21
  • Yes, I know :-) But as someone commented, it seems not to be possible with virtual layer - so this is probably the closest way to achieve the result. Sometimes a question is not so much about a particular method how to achieve someting, but simply to draw the OP to other possibilities how to achieve the same result. Commented Nov 9, 2021 at 12:48
  • Thanks @Babel for your input! I appreciate your out of the box thinking :) The reason I'm using a virtual layer here is that I need the buffer layer to be dynamically and I also want to be able to export the geometries to a file (so I need the actual geometries). I also created a spatial model which is generating a buffer layer, but this solution is not dynamically. And as far as I know Geometry by expression is also not dynamically. Commented Nov 24, 2021 at 7:06
  • Geomtry generator is dynamic, but does not create actual geometries. Geomtry by expression creates actual geometries, but is not dynamic. But combining both (depending on your workflow) could solve the problem. You say you want to export the geometries to a file: this will not be dynamic, either, and is exactly what Geomerty by expression does. Commented Nov 24, 2021 at 12:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.