1

I have a line shapefile (feature count > 600000) which has three fields: id, geometry, bufferwidth.

Which means, each line has its own buffer width.

How can I create for each feature a buffer with the relevant bufferwidth and store the created polygon? At best, as a result, I would have for each line feature a bufferpolygon within one polygon shapefile. This, as with the buffers I need to fetch point features subsequently.

Is there a way to do this in QGIS or GeoPandas? If not, I would be open to try it with another tool or method.

3
  • 4
    Are you asking how to buffer based on an attribute?
    – Erik
    Oct 17, 2023 at 15:04
  • Hi @Erik Yes, I would like to buffer based on an attribute of the line-object. Thank you for showing the several options of buffering in QGIS, but I couldn't find any of the buffer provide the option to set the buffer width according to a an attribute of a geometry?
    – i.i.k.
    Oct 17, 2023 at 15:31
  • Ever heard of data defined override?
    – Erik
    Oct 18, 2023 at 6:46

1 Answer 1

4

You can apply the buffer function like this:

import geopandas as gpd

df = gpd.read_file(r"/home/bera/Desktop/GIStest/bufferlines.geojson")
#df.columns
#Out[3]: Index(['id', 'bufferwidth', 'geometry'], dtype='object')

df["bufferpoly"] = df.apply(lambda x: x.geometry.buffer(distance=x["bufferwidth"]), axis=1)
0

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.