I'm trying to create a tool that will calculate the min depth and the max depth of a contour polygon, based on the value of the depth attributes of the surrounding contour lines. This is what I have so far.
def main(): pass if __name__ == '__main__': main() # Import system modules import arcpy import arcpy.da import arcgisscripting #Set environment settings arcpy.env.workspace = r"C:\Working" arcpy.env.overwriteOutput = True gp = arcgisscripting.create() area = "conta" line = "contl" cursor = arcpy.UpdateCursor(area) for row in cursor: arcpy.Select_analysis(row, "C:\Working\Minnesota\Shape\i_area.shp") i_area = r"C:\Working\Minnesota\Shape\i_area.shp" arcpy.SelectLayerByLocation_management(line, i_area) pcursor = arcpy.da.SearchCursor(line, "DEPTH") minDepth =10000 for row in pcursor: if int(row) < int(minDepth): minDepth = int(row) print minDepth row.setValue('DEPTHMIN', minDepth) cursor.updateRow(row) arcpy.Delete_management("C:\Working\Minnesota\Shape\i_area.shp")
I keep getting this error:
Runtime error Traceback (most recent call last): File "<string>", line 34, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\analysis.py", line 84, in Select raise e RuntimeError: Object: Error in executing tool
I think my problem has to do with trying to treat the row instance like its own feature class in order to perform the line selection. I have tried several different ways of isolating the instance into a feature class or just selecting by it. I think the arcpy. functions wont work with just a instance in a for loop.
Does anyone have other ideas?
I thought about isolating the instance outside of a for loop or cursor, but then how do I work through the shapefile?
Maybe I should try a different approach?
The path for contl is pretty much c:\working\contl. I'm not familiar with how to release cursors.
There are polygons between polylines. We use them to for a layer to add shading to for deeper water (conta is really bathymetry).
I looked up slice, and I dont see how I can use it in this case. We usually get our contour data from pubic sources, already rendered. I think I could use that method when we use a raster to get our lines.
I thought the problem was that I was trying to treat an instance in a for loop like a feature class.
Is there something else I'm missing?