Guest User

Untitled

a guest
Apr 25th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. arcpy.env.workspace = strInPath
  2. # create a set to hold the attributes
  3. attributes=set([])
  4. # ---- create a list of feature classes in the current workspace ----
  5. listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
  6. for row in listOfFeatures:
  7. attributes.add(row.getValue(strFieldName))
  8. count=1
  9. try:
  10. for row in attributes:
  11. stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
  12. strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
  13. arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
  14. count=count+1
  15. del attributes
  16. except:
  17. arcpy.AddMessage('Error found')
  18.  
  19. # Created on: 2015-05-19 15:26:10.00000
  20. # (generated by ArcGIS/ModelBuilder)
  21. # Description:
  22. # ---------------------------------------------------------------------------
  23.  
  24. # Import arcpy module
  25. import arcpy
  26.  
  27. # Load required toolboxes
  28. arcpy.ImportToolbox("Model Functions")
  29.  
  30.  
  31. # Local variables:
  32. Selected_Features = ""
  33. Value = "1"
  34.  
  35. # Process: Iterate Feature Selection
  36. arcpy.IterateFeatureSelection_mb("", "", "false")
  37.  
  38. import arcpy, os
  39.  
  40. shp = r'C:tempyourSHP.shp'
  41. outws = r'C:temp'
  42.  
  43. with arcpy.da.SearchCursor(shp, ["OBJECTID","SHAPE@"]) as cursor:
  44. for row in cursor:
  45. outfc = os.path.join(outws, "fc" + str(row[0]))
  46. arcpy.CopyFeatures_management(row[1], outfc)
  47.  
  48. import arcpy
  49.  
  50.  
  51. cursor = arcpy.SearchCursor(BOUNDARY_POLYGON_FC)
  52. for row in cursor:
  53. feature_file_path = ('{}/{}_{}.shp').format(WORKSPACE, row.OBJECTID, row.NAME)
  54. arcpy.CopyFeatures_management(row.shape, feature_file_path)
Add Comment
Please, Sign In to add comment