[Qgis-user] using difference on buffers

Chan Dolan chandler.dolan51 at gmail.com
Mon Jan 18 13:45:42 PST 2021

Yes I think you got it right!

I don't know how to use python very well, so I'd appreciate some code to
work off of. No rush though!

On Mon, Jan 18, 2021 at 2:00 PM <qgis-user at stripfamily.net> wrote:

> If I understand correctly, your problem is that the layer you are
> buffering has multiple polygons and the buffer around polygon 1 might
> intersect polygon2, so if you buffer the layer, then difference the layer
> from the buffer, you lose these overlaps. What you want is to difference
> buffer 1 with polygon 1, buffer 2 with polygon 2, etc.
> I am not aware of a way to do that from the GUI, but it's only a couple of
> line in PyQgis. You need to loop over the features of the buffer layer,
> differencing the corresponding polygon from the original layer. In my quick
> test, the FID is preserved across the two layers. The feature order appears
> to be the same, but it would be prudent to sort the two lists of features
> first to be sure of the same order. Then it's just a matter of looping over
> the features and calling the difference method on the two geometries and
> adding the result to your new layer.
> If nobody comes up with a better method or code and you don't know how to
> write Python, I'll probably have a bit of time later today to bang this out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210118/db7c6f2d/attachment.html>

More information about the Qgis-user mailing list