0

I am trying to add a raster layer in ArcPy with arcpy.mapping.Layer(Raster). By default, the layer is added with "Stretched" symbology. However, for further use of the raster, I need "Unique Values" instead.

Is there a way to directly add a Layer with the predefined symbology "unique value" to the default map document in ArcPy?

Screenshots 1 shows how the layer is added

How I want it to be added

So far I have tried to change the symbology with symbologyType, but it does not seem to work.

arcpy.gp.Reclassify_sa(ReclassifyFilteredAccumulation, "Value", "1 1;NODATA 0", ReclassifyVectorize, "DATA")
VectorizeLayer = arcpy.mapping.Layer(ReclassifyVectorize)
if VectorizeLayer.symbologyType == "UNIQUE_VALUES":
    VectorizeLayer.symbology.valueField = "VALUE"
    VectorizeLayer.symbology.addAllValues()
arcpy.mapping.AddLayer(df, VectorizeLayer,"BOTTOM")
  • 1
    From my experience, rasters will always be added with some kind of default stretch, but you can import a symbology from a layer-file that already exists. This might help you: gis.stackexchange.com/questions/122470/… – s6hebern Aug 22 '18 at 6:19
  • Well thanks for the answer. But I feel like this is way to complicated for most cases. In my case, I need another symbology so the layer can be used in ArcScan. Of course, with a more "complicated" symbology it makes sense to create an extra layer to import. – loloj0 Aug 23 '18 at 6:32

Your Answer

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

Browse other questions tagged or ask your own question.