Search code examples
pythonarcgisarcpy

Buffer Analysis using arcpy


I am looking for a piece of code which help me in converting my road centreline feature to a buffer. I have the following feature classes.

roads = "c:/base/data.gdb/roadcentreline"
roadsoutput = "c:/base/data.gdb/roadcentreline_Buffer"

Now, I want to convert this into buffer and store it in the roadsoutput. Any way to achieve this?


Solution

  • UPD: "Buffer" tool is the best for one road or for set of roads. But for a network you'd better use some specific tools from Network Analyst toolbox

    to complete previuos answer:

    Your workflow should have been something like this:

    1. Open "Search" panel in arcMap
    2. Type "Buffer"
    3. Explore answers, find suitable tool and open it. In your case it is "Buffer" from "Analysys" toolbox
    4. Explore parameters
    5. Open "Show Help" -> "Tool Help"
    6. Scroll down
    7. Find this code examples there (and also a very useful parameters table):
    import arcpy
    arcpy.env.workspace = "C:/data"
    arcpy.Buffer_analysis("roads", "C:/output/majorrdsBuffered", "100 Feet", "FULL", "ROUND", "LIST", "Distance")
    
    # Name: Buffer.py
    # Description: Find areas of suitable vegetation which exclude areas heavily impacted by major roads
    
    # import system modules 
    import arcpy
    from arcpy import env
    
    # Set environment settings
    env.workspace = "C:/data/Habitat_Analysis.gdb"
    
    # Select suitable vegetation patches from all vegetation
    veg = "vegtype"
    suitableVeg = "C:/output/Output.gdb/suitable_vegetation"
    whereClause = "HABITAT = 1" 
    arcpy.Select_analysis(veg, suitableVeg, whereClause)
    
    # Buffer areas of impact around major roads
    roads = "majorrds"
    roadsBuffer = "C:/output/Output.gdb/buffer_output"
    distanceField = "Distance"
    sideType = "FULL"
    endType = "ROUND"
    dissolveType = "LIST"
    dissolveField = "Distance"
    arcpy.Buffer_analysis(roads, roadsBuffer, distanceField, sideType, endType, dissolveType, dissolveField)
    
    # Erase areas of impact around major roads from the suitable vegetation patches
    eraseOutput = "C:/output/Output.gdb/suitable_vegetation_minus_roads"
    xyTol = "1 Meters"
    arcpy.Erase_analysis(suitableVeg, roadsBuffer, eraseOutput, xyTol)