Different default symbology in arcmap when loading rasters

370
1
01-08-2019 06:17 AM
Andreas
New Contributor III

I wrote some script tools to extract several rasters from a dem and load, order and draw them in a group layer. Extractions happens with RasterCalculator_sa and SetNull, so all Rasters have one constant value=1. When loading these rasters back into an empty document, I get different results in terms of symbology types on different machines (all 10.6.1).

Machine A loads with symbology type "Stretched", while Machine B with Symbology "UniqueValues". Because I need to set the same symbology to these layers with arcpy, this causes trouble when i use ApplySymbologyFromLayer_management to do that (You can't aply a symbology layer with a different symbolgy type).

Rasters are stored with unsigned integer in a file geodatabase with raster.save:

    rastemp = arcpy.gp.RasterCalculator_sa('("%s"  %s)*%s'%(raster_layer, queryTuple[1], queryTuple[0]))

    raster1 = arcpy.sa.SetNull(rastemp,1,"Value=0")

    raster1.save(outputname)

and later loadeds into a group layer:

    result = arcpy.MakeRasterLayer_management(raster_workspace + "\\%s"%inputname, shortname)

    arcpy.ApplySymbologyFromLayer_management(layer, symb_layer)

    arcpy.mapping.AddLayerToGroup (df, group_lyr, layer)

These are only code snippets, but I think, it's not a problem with scripting, but with a different environment or something like that. Any suggestions?

0 Kudos
1 Reply
Andreas
New Contributor III

Swapping the lines like this seems to solve the problem:

    arcpy.mapping.AddLayerToGroup (df, group_lyr, layer)

    arcpy.ApplySymbologyFromLayer_management(layer, symb_layer)

0 Kudos