Con statement

1521
5
12-10-2016 08:25 PM
EricSandoval
New Contributor

I'd like to convert all 255 cell values of one raster with the values of a different overlapping second raster. Both input rasters are 4 band, 16 bit unsigned integer tiffs.  I'm using the following con statement:  Con("ras1.tif","ras1.tif","ras2.tif","VALUE<>255").  My output raster is 8 bit unsigned integer tiff.  How do I maintain a 16 bit unsigned integer tif as the output raster and retain the 4 bands?

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

What was the result of your syntax?  Did it not do anything?  Was there an error? Did it not produce what you wanted? Hard to dissect what happened without some further comment.  

Are you using the python syntax?  check Con—Help | ArcGIS Desktop 

 since <> should probably be != Building complex statements—ArcGIS Help | ArcGIS Desktop 

Also, there is no mention of multiband rasters ... just integer and floating point suggesting single band.  

Eric_JS
New Contributor II

The syntax was fine.  It produced a result, but only as a single band .tif image.  No errors.  What I would like is a output that is 4 bands, not single band.  Also would like 16 bit unsigned integer output, not 8 bit unsigned integer. Did not use Python syntax.  And yes, the Help does not mention multibands.  I thought that a Con statement would be the best way to approach this, but if it's limited I don't want to be barking up the wrong tree.  Before I head down the scripting route, I wanted to check to see if anyone else had used the Con statement for something similar, with similar raster data.  BTW, this is for hundreds of multiband rasters and was thinking of running a Raster Calculator batch.

0 Kudos
DanPatterson_Retired
MVP Emeritus

I don't suppose 255 occurs at the same pixel locations in all bands either...otherwise it sounds like you want to either mask or clip the image.  Mosaic datasets might offer some capability, but I haven't looked in detail

JayantaPoddar
MVP Esteemed Contributor

As mentioned by Dan Patterson‌, you might need to clip the image.

Lets say you need area of interest of Raster1 and the pixel values of Raster 2.

1) First, reclassify Raster1 with a single (1) class Reclassify—Help | ArcGIS for Desktop 

2) Use the reclassified raster to create a polygon (non-simplified output. Raster to Polygon—Conversion toolbox | ArcGIS for Desktop 

3) Use the above polygon to clip Raster2 Clip—Data Management toolbox | ArcGIS for Desktop 

Keep "Use Input Features for clipping Geometry" checked.

But don't check "Maintain Clipping Extent" (Else the values might get compromised due to resampling).

You should get the clipped Raster with all the available bands of Raster2.



Think Location
Eric_JS
New Contributor II

Dan and Jayanta. 

That was pretty much my Plan B.  Looks like I'm headed to the land of Model Builder and Python.  Thank you for your time submitting comments and suggestions.