2

I have 2 rasters with the same extent. In the first raster, there are a lot of empty cells that I want to replace by the values of the second raster. I have tried Raster calculation with the following expression...

Con(IsNull("DTM_Clip_Clip1"),"DSM_Clip","DTM_Clip_Clip1")

I don't get an error message, but no output is created?

I also tried Mosaic to new raster, but also here there is no output and no error message?

I use ArcGIS 10.6 Desktop.

  • 1
    Pay close attention to the documentation for Con. The output is a Raster, which needs to be saved to be manifested permanently on disk. Please Edit the question to specify the exact version of software – Vince May 12 at 16:47
2

Quoting example three from the documentation, proper use of Con includes a final step:

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
inRaster1 = Raster("landuse")
inRaster2 = Raster("landuse2")
outCon = Con(((inRaster1 == 1) & (inRaster2 == 5)), inRaster1 + inRaster2, 99)
outCon.save("C:/sapyexamples/output/outcon")

In fact, these are the final steps of each of the five examples:

outCon2.save("C:/sapyexamples/output/outcon2")
outCon.save("C:/sapyexamples/output/outcon")
outCon.save("C:/sapyexamples/output/outcon")
outCon.save("C:/sapyexamples/output/outcon")
outCon2.save("C:/sapyexamples/output/outcon2")

So it is not exactly correct to state that "no output is created", when what was created was what is documented as being created, a Raster. Unfortunately, since you didn't assign the object to a Python variable, the object was immediately freed (pending the garbage collector's pleasure), and all access to the result was lost.

If you want to preserve your result, you'll need to capture the output and use the save method as well:

result = Con(IsNull("DTM_Clip_Clip1"),"DSM_Clip","DTM_Clip_Clip1")
result.save('my_revised_dtm.tif')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.