mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd)[0] fc = "Parcels" field = "Plot_No" cursor = arcpy.SearchCursor(fc) for row in cursor: val = row.getValue(field) for val in fc: outFC = str(val) + "_Buffer" + ".shp" arcpy.Buffer_analysis(str(val),outFC,"15 meters","FULL","ROUND","NONE")
Runtime error Traceback (most recent call last): File "<string>", line 3, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\analysis.py", line 687, in Buffer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset K does not exist or is not supported Failed to execute (Buffer).
Solved! Go to Solution.
mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd)[0] fc = 'Database Connections/TDPMode.sde/KWAGISMAIN.DBO.Parcels' field = "OBJECTID" field1 = "LGA" field2 = "District" field3 = "Block_No" field4 = "Plot_No" rows = arcpy.SearchCursor(fc) row = rows.next() while row: val = row.getValue(field) val1 = row.getValue(field1) val2 = row.getValue(field2) val3 = row.getValue(field3) val4 = row.getValue(field4) whereClause = '"OBJECTID"' + " = '" + str(val) + "'" outName = "Block_" + str(val3) + "_Plot_" + str(val4) + "_" + str(val2) + "_Area_of_" + str(val1) + "_LGA" + ".pdf" path = "C:/Users/Administrator/Documents/ArcGIS/Default.gdb/" arcpy.SelectLayerByAttribute_management("Parcels", "NEW_SELECTION", whereClause) arcpy.Buffer_analysis ("Parcels", "DataDrivenPage_Buffer", "14 meters", "FULL", "ROUND", "NONE") layer_list = "Lines","Parcels","Access_Road_Graphics","Points","Lines_Split" for layer in layer_list: arcpy.SelectLayerByLocation_management(layer, "COMPLETELY_WITHIN", "DataDrivenPage_Buffer", "", "NEW_SELECTION") exportLayer = "Points", "Lines", "Parcels","Lines_Split","Access_Road_Graphics" for layer in exportLayer: outFC = path + layer + "_New" arcpy.Clip_analysis(layer,"DataDrivenPage_Buffer",outFC) arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION") mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "Lines_New")[0] for lblClass in lyr.labelClasses: lblClass.SQLQuery = '"ParcelID"' + "=" + str(val) arcpy.RefreshActiveView() arcpy.SelectLayerByAttribute_management("DataDrivenPage_Buffer", "NEW_SELECTION", "OBJECTID = 1") df.zoomToSelectedFeatures() mxd = arcpy.mapping.MapDocument("Current") for df in arcpy.mapping.ListDataFrames(mxd): df.rotation = 0 if df.scale <= 400: df.scale = 500 if df.scale > 400 and df.scale < 1000: df.scale = 1000 else: df.scale = 2000 arcpy.mapping.ExportToPDF(mxd,r"C:\STATE\\Batch\\" + "TDP_For_" + outName) row = rows.next()
fc = "Parcels" field = "Plot_No" cursor = arcpy.SearchCursor(fc) for row in cursor: feat = row.getValue(shapefieldname) # this gives you the geometry val = row.getValue(field) outFC = str(val) + "_Buffer" + ".shp" # there should be no Null-values in "Plot_No", the values have to be unique arcpy.Buffer_analysis(feat , outFC, "15 meters", "FULL", "ROUND", "NONE")
>>> fc = "Parcels" >>> field = "Plot_No" >>> shapefieldname = "Shape" >>> cursor = arcpy.SearchCursor(fc) >>> for row in cursor: ... feat = row.getValue(shapefieldname) ... val = row.getValue(field) ... outFC = str(val) + "_Buffer" + ".shp" ... >>> arcpy.Buffer_analysis(feat , outFC, "15 meters", "FULL", "ROUND", "NONE") <Result 'C:\\Users\\Administrator\\Documents\\ArcGIS\\8_Buffer.shp'>
move the buffer-function into the loop.
The result will be a shapefile for every single row.
If your Plot_No-Field contains non-unique values you should mention marks answer.
fc = "Parcels" field = "Plot_No" cursor = arcpy.SearchCursor(fc) for row in cursor: feat = row.getValue(shapefieldname) # this gives you the geometry val = row.getValue(field) outFC = str(val) + "_Buffer" + ".shp" # there should be no Null-values in "Plot_No", the values have to be unique arcpy.Buffer_analysis(feat , outFC, "15 meters", "FULL", "ROUND", "NONE") dfAsFeature = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),df.spatialReference) arcpy.Clip_analysis(lyr,dfAsFeature,outFC) arcpy.mapping.ExportToPDF(mxd,r"C:\KWARA_STATE\\" + outName + "\\" + outName1 + "\\" + "TDP_For_" + outName2) fc = "Parcels" field = "Plot_No" cursor = arcpy.SearchCursor(fc) for row in cursor: feat = row.getValue(shapefieldname) # this gives you the geometry val = row.getValue(field) outFC = str(val) + "_Buffer" + ".shp" # there should be no Null-values in "Plot_No", the values have to be unique arcpy.Buffer_analysis(feat , outFC, "15 meters", "FULL", "ROUND", "NONE") dfAsFeature = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),df.spatialReference) arcpy.Clip_analysis(lyr,dfAsFeature,outFC) arcpy.mapping.ExportToPDF(mxd,r"C:\KWARA_STATE\\" + outName + "\\" + outName1 + "\\" + "TDP_For_" + outName2)
mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd)[0] fc = 'Database Connections/TDPMode.sde/KWAGISMAIN.DBO.Parcels' field = "OBJECTID" field1 = "LGA" field2 = "District" field3 = "Block_No" field4 = "Plot_No" rows = arcpy.SearchCursor(fc) row = rows.next() while row: val = row.getValue(field) val1 = row.getValue(field1) val2 = row.getValue(field2) val3 = row.getValue(field3) val4 = row.getValue(field4) whereClause = '"OBJECTID"' + " = '" + str(val) + "'" outName = "Block_" + str(val3) + "_Plot_" + str(val4) + "_" + str(val2) + "_Area_of_" + str(val1) + "_LGA" + ".pdf" path = "C:/Users/Administrator/Documents/ArcGIS/Default.gdb/" arcpy.SelectLayerByAttribute_management("Parcels", "NEW_SELECTION", whereClause) arcpy.Buffer_analysis ("Parcels", "DataDrivenPage_Buffer", "14 meters", "FULL", "ROUND", "NONE") layer_list = "Lines","Parcels","Access_Road_Graphics","Points","Lines_Split" for layer in layer_list: arcpy.SelectLayerByLocation_management(layer, "COMPLETELY_WITHIN", "DataDrivenPage_Buffer", "", "NEW_SELECTION") exportLayer = "Points", "Lines", "Parcels","Lines_Split","Access_Road_Graphics" for layer in exportLayer: outFC = path + layer + "_New" arcpy.Clip_analysis(layer,"DataDrivenPage_Buffer",outFC) arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION") mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "Lines_New")[0] for lblClass in lyr.labelClasses: lblClass.SQLQuery = '"ParcelID"' + "=" + str(val) arcpy.RefreshActiveView() arcpy.SelectLayerByAttribute_management("DataDrivenPage_Buffer", "NEW_SELECTION", "OBJECTID = 1") df.zoomToSelectedFeatures() mxd = arcpy.mapping.MapDocument("Current") for df in arcpy.mapping.ListDataFrames(mxd): df.rotation = 0 if df.scale <= 400: df.scale = 500 if df.scale > 400 and df.scale < 1000: df.scale = 1000 else: df.scale = 2000 arcpy.mapping.ExportToPDF(mxd,r"C:\STATE\\Batch\\" + "TDP_For_" + outName) row = rows.next()