Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. # Given a FGDB of Datasets containing parcel polygons
  2. # This script will:
  3. # Dissolve all of the parcel polygons
  4. # Merge those results
  5. # Dissolve the results again
  6. #
  7. # This creates a polygon showing at a state level what areas are covered by the polygons
  8.  
  9. # Import modules
  10. import arcpy
  11. from arcpy import env
  12. import os
  13. # Setup variables
  14. arcpy.env.overwriteOutput = True
  15.  
  16. ##########------ CHANGE THIS ----- ##################
  17. #####################################################
  18. # ----- INPUT GeoDatabase Location
  19. dbRoot = r"\fema.netr2GroupsGISGIS_SHAREData_StaticNJParcelsNew_Jersey.gdb"
  20. # ----- Output Path
  21. outPath = r"\fema.netr2GroupsGISGIS_SHAREData_StaticNJParcels"
  22. #####################################################
  23.  
  24. arcpy.env.workspace = dbRoot
  25. # ----- Output naming suffix to append
  26. suffix = "_dissolve"
  27.  
  28. print "Working in Workspace: " + arcpy.env.workspace
  29. # Iterate through the feature datasets
  30. fdlist = arcpy.ListDatasets()
  31. for fd in fdlist:
  32. print "Processing Dataset ", fd
  33. arcpy.env.workspace = dbRoot + "/" + fd
  34. print "New Workspace: " + arcpy.env.workspace
  35. # Iterate through the feature classes
  36. fclist = arcpy.ListFeatureClasses()
  37. for fc in fclist:
  38. print "Processing FC ", fc
  39. desc = arcpy.Describe(fc)
  40. if desc.shapeType == "Polygon":
  41. outFeatureClass = outPath + fc + suffix
  42. print "Dissolving to ", outFeatureClass
  43. arcpy.Dissolve_management(fc, outFeatureClass, dissolve_field="",
  44. statistics_fields="", multi_part="MULTI_PART",
  45. unsplit_lines="DISSOLVE_LINES")
  46.  
  47. print "Diossolves complete."
  48. # Iterate through the feature classes and merge
  49. arcpy.env.workspace = dbRoot
  50. mergeOut = dbRoot + "/AllMerged"
  51. fclist = arcpy.ListFeatureClasses()
  52. print "Merging to " + mergeOut
  53. arcpy.Merge_management(inputs=fclist, output=mergeOut)
  54. # Disolve Results
  55. finalDissolve = mergeOut + "ParcelCoverage"
  56. print "Final Dissolve: " + finalDissolve
  57. arcpy.Dissolve_management(mergeOut, finalDissolve, dissolve_field="",
  58. statistics_fields="", multi_part="MULTI_PART",
  59. unsplit_lines="DISSOLVE_LINES")
  60. print "Done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement