Select to view content in your preferred language

URGENT- where do I find the buffer tool with end types?

4717
21
Jump to solution
06-10-2022 02:30 AM
Labels (3)
FraserB
Emerging Contributor

https://pro.arcgis.com/en/pro-app/2.8/tool-reference/feature-analysis/create-buffers.htm

As per the website this buffer tool exists - I need the one where you can remove end types. I have used it before!! But I cannot find it now. Has it been removed? I cannot even find the standard feature analysis toolbox

https://pro.arcgis.com/en/pro-app/latest/tool-reference/feature-analysis/an-overview-of-the-standard...

 

This is pretty urgent, thanks !

 

 

0 Kudos
21 Replies
FraserB
Emerging Contributor

FraserB_0-1654854511607.png

I have this - do I need an advanced licence?

0 Kudos
Stefan_Thorn
Frequent Contributor

let me check this for you

0 Kudos
Stefan_Thorn
Frequent Contributor

I have changed from Advanced to Basic and you will see a lock below a tool and then you know if you need another license

Stefan_Thorn_0-1654855153494.png

 

0 Kudos
FraserB
Emerging Contributor

yes, so I have the tool. But not the options for side and end type. Which is odd. Especially as I know I have used them before. Do you still have access to side and end types with the basic licence?

 

0 Kudos
Stefan_Thorn
Frequent Contributor

You will need the advances license..unfortunatly. see my reply to JohannesLindner @

JohannesBierer
Frequent Contributor

If it's really urgent maybe you're able to use open source GIS like QGIS or OpenJump GIS:

https://gis.stackexchange.com/questions/115687/achieving-flat-end-line-buffers-in-qgis

0 Kudos
FraserB
Emerging Contributor

ah that is useful, thank you!

0 Kudos
JohannesLindner
MVP Alum

Open your Python window in ArcGIS Pro

JohannesLindner_0-1654863419874.png

 

Copy and Paste this script, execute

 

def _get_perpendicular_line(line_geometry, point_geometry, half_length):
    """returns a line (arcpy.Polyline) that is perpendicular to the input line

    line_geometry: arcpy.Polyline, the input line
    point_geometry: arcpy.Point or arcpy.PointGeometry, the location of the returned line
    half_length: length of the perpendicular line to each side of the input line

    """
    # clip input line at input point
    if isinstance(point_geometry, arcpy.Point):
        point_geometry = arcpy.PointGeometry(point_geometry)
    clip_extent = point_geometry.buffer(0.1).extent
    clipped_line = line_geometry.clip(clip_extent)
    # get angle of clipped line -> angle of input line at input point
    fp = arcpy.PointGeometry(clipped_line.firstPoint)
    lp = arcpy.PointGeometry(clipped_line.lastPoint)
    line_angle = fp.angleAndDistanceTo(lp, "PLANAR")[0]
    # construct nad return perpendicular line
    new_line_points = arcpy.Array([
        point_geometry.pointFromAngleAndDistance(line_angle + 90, half_length, "PLANAR").firstPoint,
        point_geometry.pointFromAngleAndDistance(line_angle - 90, half_length, "PLANAR").firstPoint,
        ])
    return arcpy.Polyline(new_line_points, spatial_reference=line_geometry.spatialReference)


def _get_buffer_with_flat_ends(line_geometry, buffer_distance):
    """returns a buffer (arcpy.Polygon) with flat ends around the input line

    line_geometry: arcpy.Polyline, the input line
    buffer_distance: distance of the line to each side of the buffer

    """
    # create a normal buffer
    buffer = line_geometry.buffer(buffer_distance)
    # get perpendicular lines at the line end points
    buffer_cutoffs = [
        _get_perpendicular_line(line_geometry, line_geometry.firstPoint, buffer_distance),
        _get_perpendicular_line(line_geometry, line_geometry.lastPoint, buffer_distance),
        ]
    # cut the buffer with those lines, keep the largest part
    for bc in buffer_cutoffs:
        buffer_parts = buffer.cut(bc)
        buffer = sorted(buffer_parts, key=lambda bp: bp.area)[-1]
    return buffer


def buffer(in_features, buffer_distance, out_path, out_name):
    """creates a polygon feature class with flat-end-buffers

    in_features: input Polyline feature class path or layer name
    buffer_distance: distance of the line to each side of the buffer
    out_path: path of the output feature class
    out_name: name of the output feature class

    """
    # read ObjectID and geometry of line fc
    in_data = [row for row in arcpy.da.SearchCursor(in_features, ["OBJECTID", "SHAPE@"])]
    # create output fc
    out_fc = arcpy.management.CreateFeatureclass(out_path, out_name, "POLYGON")
    arcpy.management.AddField(out_fc, "ORIG_FID", "LONG")
    # buffer and insert
    with arcpy.da.InsertCursor(out_fc, ["ORIG_FID", "SHAPE@"]) as cursor:
        for oid, line in in_data:
            try:
                polygon = _get_buffer_with_flat_ends(line, buffer_distance)
                cursor.insertRow([oid, polygon])
            except Exception as e:
                print(f"Could not buffer line {oid}: {e}")

 

 

Call it like this

 

buffer("TestLines", 200, "C:/Your/output/path", "FlatEndBuffer")

 

 

JohannesLindner_1-1654863553860.png

 

 

This will probably throw all kinds of errors for complicated geometries, hopefully it helps.


Have a great day!
Johannes
0 Kudos
FraserB
Emerging Contributor

ooh I will give this a try, thank you !

0 Kudos
FraserB
Emerging Contributor

it works thanks, though the get_perpendicular_line is missing underscore at front in 2nd function

0 Kudos