Select to view content in your preferred language works with multiband raster but not

10-29-2020 01:00 PM
New Contributor III

I'm trying to run Con on a specific band of a multiband geotif.  It works fine when I use but it does nothing when I use  And when I say nothing I mean no errors, no results, nothing i.e. it's a NoOp.

Anyway here's my code:

import arcpy
from import *

# set my workspace to a multiband tif.

arcpy.env.workspace = "D:/lf_composite.tif"

# now run on one band (DEM) of the tif"DEM", "400", "d:/test1.tif", "1")

# Now I have test1.tif with all pixel values of 400 - as expected.

# Now run on same band.

new_raster = Con("DEM", 400, 1)

print type(new_raster)

# Also tried this

new_raster = Con(arcpy.Raster("DEM"), 400, 1)

print type(new_raster)

# Con runs with no errors but type of new_raster doesn't print i.e. it doesn't have a type.

# I expect it to be <type 'Raster'>

How can I make work with a mutiband tif?  I want to use because I'll be stringing together muliple cons in sequence and don't want to have to deal with intermediate files that produces.

Thanks for you help.

0 Kudos
0 Replies