I made a loop to buffer several times a certain network using arcpy. What I noticed is that when I run the code, the output files do not have the attribute fields "Shape_Area" and "Shape_Length" that I get if I perform it directly via ArcMap with the geoprocessing tool "Buffer". Still, the area is shown on the map (therefore its Shape_Area and Shape_Length cannot be zero). Is there an easy way to solve this problem, since I need the "Shape_Area" parameter to work with? My buffer code is simply:

#Enter the name of the fields I want to use to buffer (they exist in "network")
Buffers = ['Name1','Name1','Name1','Name1','Name1']

env.workspace = "C:\Mydirectory"

# Enter the network to be buffered. It contains the fields listed in "Buffers"
network = "FileinMyDirectory.shp"

out = "C:\Anotherdirectory.gdb"
for buff in Buffers: 
       arcpy.Buffer_analysis(network, os.path.join(out,buff), buff,)
  • Please edit your question and use code block to clarify your question.
    – ahmadhanb
    Commented Apr 26, 2016 at 8:52
  • There seems to be some stuff missing in the code you posted. What is Buffers? Also, you keep buffering the exact same file (network) each time. Normally it should create Shape_Area and Shape_Length. Commented Apr 26, 2016 at 9:10
  • I modified my question adding what you suggested me, indeed there was a part of the code missing. And yes, I am buffering the same network several times Commented Apr 26, 2016 at 9:22
  • shapearea and shapeperimiter are automatically appended to the feature class when they are in a geodatabase. You can follow @BritishSteel for outputting to a geodatabase. If you need to use a shapefile, then you can run the Add Geometry Attributes tool with your outputs. pro.arcgis.com/en/pro-app/tool-reference/data-management/…
    – dslamb
    Commented Apr 26, 2016 at 14:46

1 Answer 1


Here is a script that would achieve it:

import arcpy
import os

arcpy.env.workspace = r"D:\Test\Data_Points"
Buffers = arcpy.ListFeatureClasses()
out = r'D:\Test\data.gdb'

for buff in Buffers:
    arcpy.Buffer_analysis(buff, os.path.join(out,buff[:-4] + '_buffer'), '20 kilometers')

print 'done'

This script takes all shapefiles from directory, buffers them, and the saves them into a geodatabase. Note that I strip the ending (.shp) of the input shapefile and that I add _buffer to the output. Both Shape_Area and Shape_Length are created.

You can see input and output here:

enter image description here

  • Thank you, according to what I understood the problem was that I was not performing the geoprocessing inside a geodatabase. Now I set everything in it and it works. Commented Apr 30, 2016 at 20:16

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.