AnsweredAssumed Answered

Conbining rasters with con/isnull

Question asked by GSCUser85 Champion on Apr 30, 2015
Latest reply on Apr 30, 2015 by GSCUser85

A few days ago I was building a cost surface (so maybe this belongs in the Spatial Analyst section).

The input was an extensive roads network, with different classes of roads (HIGHWAY", "MAJOR ROAD", etc).

I separated out each type, and rasterized the vectors, with an "impedance" value. This sort of equates to the speed of the road, or rather the times to pass through each pixel of the raster. So a highway would have less impedance than a street.

 

Then I had to combine these all back together to form my cost surface using con/isnull functions.

 

I was contemplating how to put together a multiple embedded con / isnull when I though I would give this a try.

It worked perfectly, and was very fast. The raster size was +16000 by +14000.

featList is an ordered in priority list of my road classes.

 

cntFeat = 0
for r in featList:
    rName = r[1]
    if rName in rasList:
        cntFeat += 1
        print "Processing {}".format(rName)
        if cntFeat == 1:
            Ras = Float(arcpy.Raster(rName)) / 100
        else:
            Ras2 = Float(arcpy.Raster(rName)) / 100
            Ras = Con(IsNull(Ras), Ras2, Ras)
Ras = Con(IsNull(Ras), secsPerCellOther, Ras)
Ras.save("Imp_Final")

 

This iterative approach is a good one to remember.

btw, the individual inputs were turned into LONG (16bit type) after X 100 just to save some space & time.

I could not get feature to raster to output anything other than a 64bit raster if the input variable was a double.

Also could not get env.compression to work either.

Outcomes