I'm having trouble with my Python code to automate an ArcMap process using ArcPy.

I have a shapefile of all the census sectors of a country, let's say census.shp. And I have 20 or 30 shapefiles of polygons that intersect some of these sectors, I'm naming them polygon01.shp to polygonXX.shp. This polygon shapes are updated every month so I'm writing this code to iterate through them and generate the intersection between each one of the polygon shapefiles with the census.shp and store it in a specific folder that is accessed by another applications.

I have two problems:

  1. I could manage to do all the processing and generate the intersect shapefile, polygon01_intersect.shp, but it doesn't work every time. Sometimes I have to reboot my computer to run again, otherwise arcpy returns "WARNING 000117: Warning empty output generated". I've tried to use arcpy.RepairGeometry_management before using the intersect, but I wasn't able to remove this unpredictability. Sometimes it goes smoothly, sometimes it doesn't. With the same files;
  2. Even if the first polygon shapefile intersects ok, the next one always results in the same warning 000117. So I couldn't pass the first file because the second fails.

This is my code. This is my first code using ArcPy but there are not many resources on Google to help. By the way, I have ArcMap 10.3, I'm coding the Python script with Visual Studio Code using the native ArcGIS Python compiler in C:\Python27\ArcGIS10.3\python.exe to run the script.

census = "census.shp"
dir_poly = "polygons\\"
dir_results = "results\\"
files = glob.glob(dir_poly + "*.shp")
for poly in files:
    result = dir_results + poly[poly.rfind("\\")+1:-4] + "_intersect.shp"
    print("Processing file " + poly)
    arcpy.Intersect_analysis([census, poly], result)
    print("Intersect completed: " + arcpy.GetMessages()) #this is where the warning is printed and the next lines, when I try to add a field, throw exceptions
  • @BERA All the polygons intersect census. I've tried to change the two files on the directory but it never works on the second one. I thought it could have something to do with cache, but I couldn't figure out how to clean it through the script. Jun 15, 2021 at 17:48
  • 1
    I suggest removing sbn and sbX and define extent as MAXOF.
    – FelixIP
    Jun 15, 2021 at 19:51
  • @FelixIP It seems to have worked! I'm running a couple of times before closing the question, but thanks for the tip! Jun 16, 2021 at 14:00
  • @FelixIP With or without the sbn and sbx files, it worked just adding arcpy.env.extent = "MAXOF" ! You can put it on an answer. :) Jun 16, 2021 at 19:21
  • 1
    It's ok to self answer. Please do. Sb file is overkill this time, but might help next time.
    – FelixIP
    Jun 16, 2021 at 19:22

1 Answer 1


The suggestion of the comments worked. I've just added this line in the beginning:

arcpy.env.extent = "MAXOF"

I was able to process more than one shapefile on a single run. I've tried multiple times and so far no more warnings.

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.