I would like to use ArcPy to extract the symbology colors used in a .lyr and export to a spreadsheet (like csv or dbf). Specifically, I want to be able to export RGB (and both CMYK and HSV) values.

This question was asked back in 2013: https://community.esri.com/thread/80770, but there was no solution at the time. Does anyone know of a method for this?

  • 1
    What have you tried? Where are you stuck? I don't think it's possible to do this in straight arcpy. You may need to access ArcObjects. Symbology settings can be very complicated. Solid fill, hatch, patterns, etc. – Fezter Oct 24 '17 at 22:04
  • In ArcObjects yes, arcpy no. You can use ArcObjects in arcpy, the object you're after is IFeatureLayerDrawingDescription.FeatureRenderer As IFeatureRenderer, implemented by ILayer, assuming it's a feature layer you want to get the colours for, if it's a raster layer then you want IRasterLayer.Renderer As IRasterRenderer, other types become a bit more complicated. – Michael Stimson Oct 24 '17 at 22:05
  • Take a look at gis.stackexchange.com/questions/1466/… which uses a clever approach to get the symbology info from a service definition file – Midavalo Oct 24 '17 at 22:19
  • 1
    That post is clever @Midavalo but it doesn't get the colours used, only the symbology field that is used by the renderer (if any). If you only have to do this once you can add the layer file to a new map, add a legend then export the map to TIFF and use a package like Photoshop or GIMP to sample the colours to get the RGB/CMYK values... tedious but if you don't have the time or interest to learn ArcObjects that would be the only viable method that I can think of. – Michael Stimson Oct 24 '17 at 22:25

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.