I am trying to run the contour tool on arcpy in Python IDLE 2.7 to produce contour polygons. Moreover, I have 189 grid polygons, and I would like to set each of these as processing extent, and the script will create separate contour polygons based on these looped extents. I tried the following code:
import os
from arcpy import env
from arcpy.sa import *
arcpy.env.workspace = 'D:\Spring2020\VIC\EB_Correct_File_ArcGIS\Grids'
Grids = r'D:\Spring2020\VIC\EB_Correct_File_ArcGIS\Grids'
List = arcpy.ListFiles("*.shp")
print List
DEM = r'D:\Spring2020\VIC\EB_Correct_File_ArcGIS\DEM.tif'
for i in range(189):
arcpy.env.extent = (r"D:\Spring2020\VIC\EB_Correct_File_ArcGIS\Grids"+".shp")
arcpy.gp.Contour_sa("DEM", "D:/Spring2020/VIC/EB_Correct_File_ArcGIS/Contours/*.shp", "490.848333", "1742.06", "1", "CONTOUR_POLYGON", "")
List of grid shape files:
1.shp, 2.shp, 3.shp ..... 189.shp
Traceback (most recent call last):
File "D:/Spring2020/VIC/Contours.py", line 16, in <module>
arcpy.env.extent = (List)
File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\geoprocessing\_base.py", line 541, in set_
self[env] = val
File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\geoprocessing\_base.py", line 601, in __setitem__
ret_ = setattr(self._gp, item, value)
RuntimeError: Object: Error in accessing environment <extent>
I think there is a problem with line 16 syntax