Hi all,
I have a piece of code where I want the user to be able to specify the rasters that will be used in the mosaic tool etc but I'm having a bit of trouble. Could anybody please point me in the right direction regarding what I'm doing wrong and how to get the user to be able to input the rasters below. Thank you.
I have a piece of code where I want the user to be able to specify the rasters that will be used in the mosaic tool etc but I'm having a bit of trouble. Could anybody please point me in the right direction regarding what I'm doing wrong and how to get the user to be able to input the rasters below. Thank you.
Code:
# Prints the length of sys.argv and the first argument
print 'Number of Arguments = ', len(sys.argv)
print 'First Argument sys.argv[0] = ', sys.argv[0]
if len(sys.argv)==1:
Workspace = raw_input("Please enter the folder path of your workspace")
Raster_1 = raw_input("Please enter the path to the first raster")
Raster_2 = raw_input("Please enter the path to the second raster")
Raster_3 = raw_input("Please enter the path to the third raster")
Raster_4 = raw_input("Please enter the path to the fourth raster")
BufferDistance = raw_input("Please enter the required buffer distance")
else:
Workspace = sys.argv[1]
Raster_1 = sys.argv[2]
Raster_2 = sys.argv[3]
Raster_3 = sys.argv[4]
Raster_4 = sys.argv[5]
BufferDistance = sys.argv[6]
#User enters the workspace path
arcpy.env.workspace = out_path = Workspace
print 'Workspace Set'
# Create Raster Dataset
out_name = "R_Dataset"
# Run the Create Raster Dataset Script
arcpy.CreateRasterDataset_management (out_path, out_name, "", "8_BIT_UNSIGNED", "", "1", "", "PYRAMIDS -1 NEAREST DEFAULT 75 NO_SKIP", "128 128", "LZ77", "")
# Mosaic Rasters into the Raster Dataset
Raster_inputs = (sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
# Set the target to the Raster Dataset that was already created