I'm creating a model in the ArcGIS 10.3 Model Builder and have problems to get the select data tool to work.At first the complete model: IHS-KlassifizierungWith the Select Data tool (Input Data Element: Raster, Child Data Element: %layerband%_1) I'm selecting Band_1 or Band_3 from a Rasterfile, for this I need to check with Calculate Value if the Bands are called "Layer_x" or "Band_x" (In my raster data are different names and I mustn't change them), with the following code:
def x(Rasterfile):import arcpy # I think this is not necessary, but I'm not sure desc = arcpy.Describe(Rasterfile) # Get the necessary informationbandlayer = desc.children[0].name # select the first bandergebnis = str(bandlayer.split("_",1)[0]) # Remove the _ and the number from the Namereturn ergebnisas Expression I use x("%Rasterfile%") and Date type String.
When I run the model on my sample data (just one raster file) I get the following error:
Executing: IHS-Klassifizierung W:\arctest W:\arctest\outputStart Time: Tue Nov 03 16:39:06 2015Executing (Iterate Rasters): IterateRasters W:\arctest # # NOT_RECURSIVEStart Time: Tue Nov 03 16:39:06 2015Succeeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,52 seconds)Executing (Parse Path (2)): ParsePath W:\arctest\orthoclip.tif FILEStart Time: Tue Nov 03 16:39:07 2015Succeeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,00 seconds)Executing (Calculate Value): CalculateValue x("orthoclip.tif") "def x(Rasterfile):\n import arcpy desc = arcpy.Describe(Rasterfile) bandlayer = desc.children[0].name ergebnis = str(bandlayer.split("_",1)[0]) return ergebnis\n" StringStart Time: Tue Nov 03 16:39:07 2015Value = BandSucceeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,04 seconds)Executing (Select Data): SelectData W:\arctest\orthoclip.tif Band_1Start Time: Tue Nov 03 16:39:07 2015**Failed to execute. Parameters are not valid.****ERROR 000800: The value is not a member of Band_1 | Band_2 | Band_3 | Band_4.**Failed to execute (Select Data).Failed to execute (IHS-Klassifizierung).If I try it without the Calculate Value Tool and put in the Select Data- Child Data Element directly Band_1 or Band_3 it works.
EDIT: Sometimes it happens (I can't figure out why and I don't connect it to changes witch I made) that the following error appears:
Executing: IHS-Klassifizierung W:\arctest W:\arctest\outputStart Time: Wed Nov 04 13:23:47 2015Executing (Iterate Rasters): IterateRasters W:\arctest # # NOT_RECURSIVEStart Time: Wed Nov 04 13:23:47 2015Succeeded at Wed Nov 04 13:23:47 2015 (Elapsed Time: 0,35 seconds)Executing (Parse Path (2)): ParsePath W:\arctest\orthoclip.tif FILEStart Time: Wed Nov 04 13:23:47 2015Succeeded at Wed Nov 04 13:23:47 2015 (Elapsed Time: 0,00 seconds)Executing (Calculate Value): CalculateValue x("orthoclip.tif") "def x(Rasterfile):\n import arcpy\n desc = arcpy.Describe(Rasterfile) \n bandlayer = desc.children[0].name \n ergebnis = bandlayer.split("_",1)[0] \n return ergebnis\n" StringStart Time: Wed Nov 04 13:23:47 2015ERROR 000539: Error running expression: x("orthoclip.tif") Traceback (most recent call last): File "", line 1, in File "", line 3, in x File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\__init__.py", line 1246, in Describe return gp.describe(value) File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe self._gp.Describe(*gp_fixargs(args, True)))IOError: "orthoclip.tif" does not existFailed to execute (Calculate Value).Failed at Wed Nov 04 13:23:48 2015 (Elapsed Time: 0,28 seconds)Failed to execute (IHS-Klassifizierung).Failed at Wed Nov 04 13:23:48 2015 (Elapsed Time: 0,93 seconds)
أكثر...
def x(Rasterfile):import arcpy # I think this is not necessary, but I'm not sure desc = arcpy.Describe(Rasterfile) # Get the necessary informationbandlayer = desc.children[0].name # select the first bandergebnis = str(bandlayer.split("_",1)[0]) # Remove the _ and the number from the Namereturn ergebnisas Expression I use x("%Rasterfile%") and Date type String.
When I run the model on my sample data (just one raster file) I get the following error:
Executing: IHS-Klassifizierung W:\arctest W:\arctest\outputStart Time: Tue Nov 03 16:39:06 2015Executing (Iterate Rasters): IterateRasters W:\arctest # # NOT_RECURSIVEStart Time: Tue Nov 03 16:39:06 2015Succeeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,52 seconds)Executing (Parse Path (2)): ParsePath W:\arctest\orthoclip.tif FILEStart Time: Tue Nov 03 16:39:07 2015Succeeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,00 seconds)Executing (Calculate Value): CalculateValue x("orthoclip.tif") "def x(Rasterfile):\n import arcpy desc = arcpy.Describe(Rasterfile) bandlayer = desc.children[0].name ergebnis = str(bandlayer.split("_",1)[0]) return ergebnis\n" StringStart Time: Tue Nov 03 16:39:07 2015Value = BandSucceeded at Tue Nov 03 16:39:07 2015 (Elapsed Time: 0,04 seconds)Executing (Select Data): SelectData W:\arctest\orthoclip.tif Band_1Start Time: Tue Nov 03 16:39:07 2015**Failed to execute. Parameters are not valid.****ERROR 000800: The value is not a member of Band_1 | Band_2 | Band_3 | Band_4.**Failed to execute (Select Data).Failed to execute (IHS-Klassifizierung).If I try it without the Calculate Value Tool and put in the Select Data- Child Data Element directly Band_1 or Band_3 it works.
EDIT: Sometimes it happens (I can't figure out why and I don't connect it to changes witch I made) that the following error appears:
Executing: IHS-Klassifizierung W:\arctest W:\arctest\outputStart Time: Wed Nov 04 13:23:47 2015Executing (Iterate Rasters): IterateRasters W:\arctest # # NOT_RECURSIVEStart Time: Wed Nov 04 13:23:47 2015Succeeded at Wed Nov 04 13:23:47 2015 (Elapsed Time: 0,35 seconds)Executing (Parse Path (2)): ParsePath W:\arctest\orthoclip.tif FILEStart Time: Wed Nov 04 13:23:47 2015Succeeded at Wed Nov 04 13:23:47 2015 (Elapsed Time: 0,00 seconds)Executing (Calculate Value): CalculateValue x("orthoclip.tif") "def x(Rasterfile):\n import arcpy\n desc = arcpy.Describe(Rasterfile) \n bandlayer = desc.children[0].name \n ergebnis = bandlayer.split("_",1)[0] \n return ergebnis\n" StringStart Time: Wed Nov 04 13:23:47 2015ERROR 000539: Error running expression: x("orthoclip.tif") Traceback (most recent call last): File "", line 1, in File "", line 3, in x File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\__init__.py", line 1246, in Describe return gp.describe(value) File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe self._gp.Describe(*gp_fixargs(args, True)))IOError: "orthoclip.tif" does not existFailed to execute (Calculate Value).Failed at Wed Nov 04 13:23:48 2015 (Elapsed Time: 0,28 seconds)Failed to execute (IHS-Klassifizierung).Failed at Wed Nov 04 13:23:48 2015 (Elapsed Time: 0,93 seconds)
أكثر...