How to use CON function

1478
9
02-27-2012 05:46 AM
DarleneWilcox
New Contributor III
I have two rasters -- one is an ORIGINAL_DEM, the second has some CORRECTED_DEM elevation values and otherwise is NODATA.

What I want is to create a new raster, where the values are the CORRECTED elevation values where there are corrected elevation values, and otherwise are the original DEM values.

In the Tool, I use the following:

Input conditional raster:  CORRECTED_DEM

Expression:  I tried leaving this blank, I tried "VALUE" > 0, and I tried "VALUE" <> NULL

Input true raster:  CORRECTED_DEM

Input false raster:  ORIGINAL_DEM

In each of these cases, I get the corrected DEM values ONLY -- the rest of the values are NODATA -- that is, I'm not getting the original DEM values at all!

Thanks for any help....
0 Kudos
9 Replies
Robert_LeClair
Esri Notable Contributor
Darlene -

Would this work in the tool GUI:

Input conditional raster: CORRECTED_DEM

Expression: NOT("VALUE" IS NULL)

Input true raster: CORRECTED_DEM

Input false raster: ORIGINAL_DEM

Good luck!

Robert LeClair
Esri-Denver
0 Kudos
DarleneWilcox
New Contributor III
Robert,

Well, that gave me completely inexplicable results.

Original_DEM:  3251 rows x 4618 columns, 3m cellsize.  Min elevation, 262.03m.  Max elevation 305.78m, Mean elevation 280.69m (values rounded).
Corrected_DEM:  3251 rows x 4618 columns, 3m cellsize.  Min elevation, 265.31m.  Max elevation 299.39m, Mean elevation 283.40m (values rounded).

The Corrected_DEM was created this way:  Line segments were digitized where culverts needed to be "burned in" to the elevation model.  Through a number of moves the line segments became the Corrected_DEM, which is NODATA off the line segments and interpolated elevation values along the line segments (now @ 10 gridcells long, each).  Also, I set the environment to be the same extent and cell size as, and had the line segments snap to, the Original_DEM. 

When I did my attempts at the CON, I got ... exactly the same as my Corrected_DEM.  When I did YOUR version, I got this oddball result.  The properties indicate the same number of rows and columns, the same cell size, but the Min, Max, and Mean elevation values are all 264.57m (rounded) and all the values are null except for one cluster of gridcells in the far upper left of the DEM measuring about 383m x 383m.  This is no where near any of the corrections.

I did this twice -- once just putting in your suggestions, one using your suggestions AND setting the environment to match the Original_DEM.  Same results both times.

This should NOT be so difficult!  Any further ideas?  Thanks, Darlene
0 Kudos
Robert_LeClair
Esri Notable Contributor
Darlene - interesting...I'm assuming your rasters are in the same projection, correct?  If you're interested, you can send me your rasters to rleclair at esri dot com.  I can work with the scenario and attempt to resolve it.  Please advise.
0 Kudos
DarleneWilcox
New Contributor III
Darlene - interesting...I'm assuming your rasters are in the same projection, correct?  If you're interested, you can send me your rasters to rleclair at esri dot com.  I can work with the scenario and attempt to resolve it.  Please advise.


Robert, Yes, both are NAD83 UTM16N.

I'll be glad to zip them up and email them to you, because I have to embrace ArcGIS (I'm an old, old dog, who still fumbles a bit -- make that more than a bit -- with the new tricks).  Because I actually have to advance through the project, though, I reverted back to the old ways:  In ArcView3.3, this produced the correct results:

( [Culvert_1].IsNull.Con([Cksw_03m_v0],[Culvert_1]))

Thanks so much.  Darlene
0 Kudos
Robert_LeClair
Esri Notable Contributor
Understand Darlene - no worries.  I too am an "old" dog as well - ArcInfo Workstation (v. 5.0).  Progressed through ArcView 1.0, 2.0, 3.x and now the ArcGIS releases v. 8-10.0.  Cheers!
0 Kudos
Robert_LeClair
Esri Notable Contributor
Darlene -

Here's a thought - instead of using the CON function, try the Raster Calculator instead with the following syntax:

Con(IsNull("Corrected_DEM"),�?�Original_DEM, "Corrected_DEM")

What is the result?  Please advise.

Regards,

Robert
0 Kudos
ShaunDillon
New Contributor
Hi
Dont know if I should start my own thread/question, but I think my problem is quite similar to this.
I am trying to cut streams into my DEM. I have made my streams into rasters with a value of -1 (meters) with the rest of the raster having NoData value. I then want to make a conditional (or should I use Pick) to make a new Raster where the elevation is -1 where the streams are and otherwise have the value of the DEM. I have also tried to make a conditional expression in the Single Output Map Algebra without succes.
Part of my problem is that I simply do not know where you write the expressions (such as "Con(IsNull("Corrected_DEM"),�?�Original_DEM, "Corrected_DEM")". I use ArcGIS 9.3.1 but have mainly used the toolbox tool "Con".
Can someone explain to a newbie?
Regards Shaun
0 Kudos
JeffreySwain
Esri Regular Contributor
While Robert discussed the coordinatesystem, he did not discuss the spatial extents.  I believe the reason that you are getting the incomplete results are that the spatial extents are different or at least on one raster there are nodata values in places that you would like to replace.  There is a blog that discusses some of the options, but basically if you want continous data from both rasters, you have to be sure you have complete coverage for both rasters. This can be obtained best by mosaicking the two rasters together to get the combined spatial extent and then convert that raster to a constant raster with a 0 value.  This will create the combined spatial extent that you want.  Afterwards create two new rasters, but mosaicking the individual rasters with the new base and be sure to select maximum for the mosaic method.  Now the new rasters will maintain the same values, but have a shared extent.  Your con statement should work with the original syntax now.
0 Kudos
BartholomewPenchent
New Contributor
CONDITION:

Con(IsNull("Correct_Values_Raster"),"Original_Raster","Correct_Values_Raster")


Explanation:

--- Begin Statement ---

Where the "Correct_Values_Raster" equals <NULL>,

Use the "Original_Raster",

Else use the "Correct_Values_Raster"

---End Statement ---

I used this to 'burn in' Culverts to allow for correct stream production of a Hydrology Model.

Set Processing Extent and Snap Raster to the "Original_Raster" under the Environment Settings.

The output is a "New_Raster_DEM" with culvert cuts in the right places.
0 Kudos