I am a python begginer; I found a script that "BARBOSSA" posted in the "blog" ( Append or merge consecutive line segments (contours) as one single line of the same elevation value)
I am trying to use it to merge 2 shapefiles (1 ft -contours):N1_Terrain_SurfaceContour ( 0 -12) ft elevetions and N1_Terrain_SurfaceContour (0-11)
These are located at my workspace: C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contour.mdb
Each one has the same fields: OBJECTID, Shape*, Contour and Shape_Lenght. I used "Contour" instead "ELEV_FT" in the script (as you suggested).
I got the following ERROR (Parameters are not valid):
Traceback (most recent call last): File "C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contourlines merge BREVARD.py", line 35, in arcpy.Merge_management(contourList, "contour_merge.shp") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3788, in Merge raise eExecuteError: Failed to execute. Parameters are not valid.ERROR 000735: Input Datasets: Value is requiredFailed to execute (Merge).I will appreciate a lot if you help me with this matter, I am doint it as Volunteer for Brevard county in Florida.
This is the script that I adapted from yours:
Contour_Merge_And_Dissolve.py - CONTOUR PJ BREVARD COUNTY
# Import modulesimport arcpyarcpy.env.workspace = "C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contour.mdb"from arcpy import env# Define functionsdef min_max(featureClass, fieldName): listItems = [] rows = arcpy.SearchCursor(featureClass) for row in rows: listItems.append(row.getValue(fieldName)) del rows listItems.sort() listMin = listItems[0] listMax = listItems[-1] return listMin, listMax# ArgumentscontourList = arcpy.GetParameterAsText(0) #input shapefiles, ElevationContoursoutFolder = arcpy.GetParameterAsText(1) #output folder# set workspace and overwrite optionarcpy.env.workspace = outFolderarcpy.env.overwriteOutput = Truearcpy.env.outputZFlag = "Disabled"arcpy.env.outputMFlag = "Disabled"# local variablesdissolveFields = ["Contour"] # change field name here# Process: Mergearcpy.AddMessage("Merging contours...")arcpy.Merge_management(contourList, "contour_merge.shp")# Get Min/Max values of Contour fieldft_min, ft_max = min_max("contour_merge.shp", "Contour") # change field name hereft_range = ft_max - ft_minarcpy.AddMessage("Contour MIN: " + str(ft_min))arcpy.AddMessage("Contour MAX: " + str(ft_max))# Set progressorarcpy.SetProgressor("step", "Breaking apart contours...", 0, ft_range, 1)arcpy.AddMessage("Breaking apart contours...")# Break apart and dissolve for each Contour valuemergeList = []counter = ft_minwhile counter
I am trying to use it to merge 2 shapefiles (1 ft -contours):N1_Terrain_SurfaceContour ( 0 -12) ft elevetions and N1_Terrain_SurfaceContour (0-11)
These are located at my workspace: C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contour.mdb
Each one has the same fields: OBJECTID, Shape*, Contour and Shape_Lenght. I used "Contour" instead "ELEV_FT" in the script (as you suggested).
I got the following ERROR (Parameters are not valid):
Traceback (most recent call last): File "C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contourlines merge BREVARD.py", line 35, in arcpy.Merge_management(contourList, "contour_merge.shp") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3788, in Merge raise eExecuteError: Failed to execute. Parameters are not valid.ERROR 000735: Input Datasets: Value is requiredFailed to execute (Merge).I will appreciate a lot if you help me with this matter, I am doint it as Volunteer for Brevard county in Florida.
This is the script that I adapted from yours:
Contour_Merge_And_Dissolve.py - CONTOUR PJ BREVARD COUNTY
# Import modulesimport arcpyarcpy.env.workspace = "C:\Users\efa8\Documents\AA_NRMD_Bvrd\CONTOUR PJ\Contour.mdb"from arcpy import env# Define functionsdef min_max(featureClass, fieldName): listItems = [] rows = arcpy.SearchCursor(featureClass) for row in rows: listItems.append(row.getValue(fieldName)) del rows listItems.sort() listMin = listItems[0] listMax = listItems[-1] return listMin, listMax# ArgumentscontourList = arcpy.GetParameterAsText(0) #input shapefiles, ElevationContoursoutFolder = arcpy.GetParameterAsText(1) #output folder# set workspace and overwrite optionarcpy.env.workspace = outFolderarcpy.env.overwriteOutput = Truearcpy.env.outputZFlag = "Disabled"arcpy.env.outputMFlag = "Disabled"# local variablesdissolveFields = ["Contour"] # change field name here# Process: Mergearcpy.AddMessage("Merging contours...")arcpy.Merge_management(contourList, "contour_merge.shp")# Get Min/Max values of Contour fieldft_min, ft_max = min_max("contour_merge.shp", "Contour") # change field name hereft_range = ft_max - ft_minarcpy.AddMessage("Contour MIN: " + str(ft_min))arcpy.AddMessage("Contour MAX: " + str(ft_max))# Set progressorarcpy.SetProgressor("step", "Breaking apart contours...", 0, ft_range, 1)arcpy.AddMessage("Breaking apart contours...")# Break apart and dissolve for each Contour valuemergeList = []counter = ft_minwhile counter