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.

BERA
  • 72,339
  • 13
  • 72
  • 161
i.i.k.
  • 1,427
  • 5
  • 11

1 Answers1

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)

BERA
  • 72,339
  • 13
  • 72
  • 161