3

I have these transects I've buffered as training data, but now we had "edges" defined where we need a simple buffer on ONE side of the line. I run my scripts within Jupyter Notebooks, so it needs to work standalone. Right now my buffer code looks like this:

lines['geometry'] = lines.buffer(1, cap_style=3)

lines.to_file(linesBufferFolder + "\\Lines_Buffer")

This creates a 1m buffer on both sides with end caps. Like this:

picture

I essentially need to bisect that polygon, and only keep the "left" side based on the order which the points go. My initial thought was to use a one sided buffer, but I can't find any documentation for that in GeoPandas Geometric Manipulation documentations.

My other idea was to simply erase half of the polygon I currently have, but again, to get that overlay I would think I would need to buffer the other side, bringing me back to my original issue. I know how to manually do one side buffers, but finding a Python library that uses it other than ArcPy is stumping me.

1 Answer 1

6

You can do single side buffer using Geopandas but you need shapely version 1.7 or upper version (due to https://github.com/Toblerity/Shapely/issues/727#issuecomment-499900749) I do reprojection to a meters based projection in my sample as buffer unit is the projection unit and using degrees is not recommended.

import geopandas

lines = geopandas.read_file('https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_rivers_lake_centerlines.geojson')

# Buffer negative or positive depending if left or right buffer compared to line orientation
buffered_lines_positive = lines.to_crs('EPSG:3857').buffer(20000, single_sided=True)
buffered_lines_negative = lines.to_crs('EPSG:3857').buffer(-20000, single_sided=True)
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.