I have a python script that, as part of the code, separates raster bands and then uses Con to identify black pixels; like this:
MyRaster = r"MyRaster.tif"
redband = MyRaster + "\Band_1"
greenband = MyRaster + "\Band_2"
blueband = MyRaster + "\Band_3"
BlackPixels = Con (((Raster(redband)==0 & (Raster(greenband)==0..................
However, I'm now trying to make this script into a python toolbox but the bands are not being recognised; like this:
def getParameterInfo(self):
inRaster = arcpy.Parameter(
displayName="input raster",
name="inraster",
datatype=["GPRasterLayer","DERasterDataset"],
parameterType="Required",
direction="Input")
.......
return [inRaster]
def execute (self,parameters,messages):
MyRaster = parameters[0].valueAsText
redband = MyRaster + "/Band_1"
greenband = MyRaster + "/Band_2"
blueband = MyRaster + "/Band_3"
BlackPixels = Con (((Raster(redband)==0 & (Raster(greenband)==0..................
I get following message
RuntimeError: ERROR 000732: Input Raster: Dataset MyRaster.tif/Band_1 does not exist.
What am I doing wrong?