arcpy.env.cellSize = "90" arcpy.env.workspace = r'G:\Xcel\Route Tool\Potter\Scratch.gdb' landuseRaster = r'G:\Xcel\Route Tool\Potter\Data.gdb\Potter_Randall_Landuse_Raster' slope_Reclass_Raster = r'G:\Xcel\Route Tool\Potter\Scratch.gdb\slope_Reclass' #Generate a list identifying what the individual input values should be reclassified as. remapLanduse = RemapValue([['Cropland and pasture',2],['Herbaceous Rangeland',1],['Nonforested wetland',10],['Other agricultural land',1],['Strip mines, quarries and gravel pits',2], [ 'Mixed rangeland',1],['Lakes',10],['Residential',3],['Commercial and Services',3],['Confined feeding operations',3],['Transportation, communications and services',10], ['Transitional areas',3],['Shrub-brushland rangeland',1],['Other urban or built-up land',3],['Bare exposed rock',3],['Industrial',2],['Reservoirs',10],['Forested wetland',10],['Mixed urban or built-up land',3]]) remapSlope = RemapValue([[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]]) #Define the input rasters, the field identifying the input values, the remap of their values, the weight of each raster, and the evaluation scale to use in the Weighted Overlay tool. myWOTable = WOTable([[landuseRaster, 80, "LANDUSE", remapLanduse], [slope_Reclass_Raster, 20, "Value", remapSlope], ], [1, 10, 1]) outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("Creating weighted raster...") weighted_Raster = env.workspace + '\weighted_Raster' outWeightedOverlay.save(weighted_Raster)
subs = arcpy.GetParameterAsText(0) Field = arcpy.GetParameterAsText(1) originValue = arcpy.GetParameterAsText(2) destValue = arcpy.GetParameterAsText(3) lines = arcpy.GetParameterAsText(4) Dem = arcpy.GetParameterAsText(5) landuseRaster = arcpy.GetParameterAsText(6) outwork = arcpy.GetParameterAsText(7) arcpy.env.workspace = outwork + "\Scratch.gdb"
#Generate a list identifying what the individual input values should be reclassified as. remapLanduse = RemapValue([['Cropland and pasture',2],['Herbaceous Rangeland',1],['Nonforested wetland',10],['Other agricultural land',1],['Strip mines, quarries and gravel pits',2], [ 'Mixed rangeland',1],['Lakes',10],['Residential',3],['Commercial and Services',3],['Confined feeding operations',3],['Transportation, communications and services',10], ['Transitional areas',3],['Shrub-brushland rangeland',1],['Other urban or built-up land',3],['Bare exposed rock',3],['Industrial',2],['Reservoirs',10],['Forested wetland',10],['Mixed urban or built-up land',3]]) remapSlope = RemapValue([[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]]) #Define the input rasters, the field identifying the input values, the remap of their values, the weight of each raster, and the evaluation scale to use in the Weighted Overlay tool. myWOTable = WOTable([[landuseRaster, 80, "LANDUSE", remapLanduse], [slope_Reclass_Raster, 20, "Value", remapSlope], ], [1, 10, 1]) outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("Creating weighted raster...") weighted_Raster = env.workspace + '\weighted_Raster' outWeightedOverlay.save(weighted_Raster)
Solved! Go to Solution.
arcpy.AddMessage("Computing slope Reclass...") outSlice = Slice('slope_Raster', 10, "NATURAL_BREAKS") slope_Reclass_Raster = outSlice.save('slope_Reclass') slope_Reclass_Raster = "slope_Reclass"
I think the issue is you are not escaping the '\' characters when you set the workspace path and when you create the output path string. You should use r"\Scratch.gdb" or "\\Scratch.gdb" any time you need to construct a path.
arcpy.env.cellSize = "90" arcpy.env.workspace = r'G:\Xcel\Route Tool\Potter\Scratch.gdb' landuseRaster = r'G:\Xcel\Route Tool\Potter\Data.gdb\Potter_Randall_Landuse_Raster' slope_Reclass_Raster = r'G:\Xcel\Route Tool\Potter\Scratch.gdb\slope_Reclass' #Generate a list identifying what the individual input values should be reclassified as. remapLanduse = RemapValue([['Cropland and pasture',2],['Herbaceous Rangeland',1],['Nonforested wetland',10],['Other agricultural land',1],['Strip mines, quarries and gravel pits',2], [ 'Mixed rangeland',1],['Lakes',10],['Residential',3],['Commercial and Services',3],['Confined feeding operations',3],['Transportation, communications and services',10], ['Transitional areas',3],['Shrub-brushland rangeland',1],['Other urban or built-up land',3],['Bare exposed rock',3],['Industrial',2],['Reservoirs',10],['Forested wetland',10],['Mixed urban or built-up land',3]]) remapSlope = RemapValue([[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]]) #Define the input rasters, the field identifying the input values, the remap of their values, the weight of each raster, and the evaluation scale to use in the Weighted Overlay tool. myWOTable = WOTable([[landuseRaster, 80, "LANDUSE", remapLanduse], [slope_Reclass_Raster, 20, "Value", remapSlope], ], [1, 10, 1]) outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("Creating weighted raster...") outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("The current workspace is: %s" % env.workspace) arcpy.AddMessage("Saving weighted raster...") outWeightedOverlay.save(env.workspace + '\\weighted_Raster')
subs = arcpy.GetParameterAsText(0) Field = arcpy.GetParameterAsText(1) originValue = arcpy.GetParameterAsText(2) destValue = arcpy.GetParameterAsText(3) lines = arcpy.GetParameterAsText(4) Dem = arcpy.GetParameterAsText(5) landuseRaster = arcpy.GetParameterAsText(6) outwork = arcpy.GetParameterAsText(7) #create *.gdb to store scratch intermediate data arcpy.CreateFileGDB_management(outwork, "Scratch.gdb") env.workspace = outwork + "\\Scratch.gdb" ... remapLanduse = RemapValue([['Cropland and pasture',2],['Herbaceous Rangeland',1],['Nonforested wetland',10],['Other agricultural land',1],['Strip mines, quarries and gravel pits',2], [ 'Mixed rangeland',1],['Lakes',10],['Residential',3],['Commercial and Services',3],['Confined feeding operations',3],['Transportation, communications and services',10], ['Transitional areas',3],['Shrub-brushland rangeland',1],['Other urban or built-up land',3],['Bare exposed rock',3],['Industrial',2],['Reservoirs',10],['Forested wetland',10],['Mixed urban or built-up land',3]]) remapSlope = RemapValue([[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]]) #Define the input rasters, the field identifying the input values, the remap of their values, the weight of each raster, and the evaluation scale to use in the Weighted Overlay tool. myWOTable = WOTable([[landuseRaster, 80, "LANDUSE", remapLanduse], [slope_Reclass_Raster, 20, "Value", remapSlope], ], [1, 10, 1]) outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("Creating weighted raster...") outWeightedOverlay = WeightedOverlay(myWOTable) arcpy.AddMessage("The current workspace is: %s" % env.workspace) arcpy.AddMessage("Saving weighted raster...") outWeightedOverlay.save(env.workspace + '\\weighted_Raster')
Well, I guess I would just suggest printing all of the parameters when you get them as text at the beginning of the script, and also printing all of the corresponding variables in the hard-coded version. It sounds like there is some value or object type issue. Perhaps you are getting something as text that you previously used as an object? I don't know a whole lot about raster processing, so can't be much more help...
arcpy.AddMessage("Computing slope Reclass...") outSlice = Slice('slope_Raster', 10, "NATURAL_BREAKS") slope_Reclass_Raster = outSlice.save('slope_Reclass') slope_Reclass_Raster = "slope_Reclass"