<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS python HSV to RGB colour conversion in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1701007#M27726</link>
    <description>&lt;P&gt;Nice work! Thank you! You just saved me a mess of boring clicks.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 May 2026 20:32:01 GMT</pubDate>
    <dc:creator>Jeff-Reinhart</dc:creator>
    <dc:date>2026-05-08T20:32:01Z</dc:date>
    <item>
      <title>ArcGIS python HSV to RGB colour conversion</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1381428#M27159</link>
      <description>&lt;P&gt;I am trying to populate 3 fields in a feature class with the symbology colour in RGB.&lt;BR /&gt;My conversion code takes the H, S and V values given by the layer.symbology.renderer.symbol.color function.&lt;/P&gt;&lt;P&gt;A sample of the output from the color function is:&amp;nbsp; {'HSV': [61, 50, 55, 100]}&lt;/P&gt;&lt;P&gt;The values must be munged to cater for the ArcGIS &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/raster-functions/color-model-conversion-function.htm" target="_self"&gt;colour model&lt;/A&gt; ;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def colourHSVtoRGB(self,H,S,V):
        # The ArcGIS HSV model is strange - Hue 0-240, Saturation 0 - 255, Value 0 - 255
        from matplotlib.colors import hsv_to_rgb
        # Convert hval to 360 and make it 0 - 1
        hval = 3.6 * (H / 240)
        sval = S / 255
        vval = V / 255

        invals = [hval, sval, vval]
        rg = hsv_to_rgb(invals)
        R = rg[0]
        G = rg[1]
        B = rg[2]

        # Convert to 0 - 255
        R = int(round((R * 255), 0))
        G = int(round((G * 255), 0))
        B = int(round((B * 255), 0))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately this gives the incorrect RGB values.&lt;/P&gt;&lt;P&gt;From a &lt;A href="https://www.rapidtables.com/convert/color/hsv-to-rgb.html" target="_self"&gt;colour web site&lt;/A&gt;, the RGB for HSV = 61, 50, 55 should be 139, 140, 70, which also looks like the correct colour.&lt;/P&gt;&lt;P&gt;My function outputs RGB values;&amp;nbsp; 49, 55, 44 - clearly wrong.&lt;BR /&gt;The input values to the matplotlib function are all 0 - 1. I'm sure my interpretation of the calculation for this input could use some improvement.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 03:06:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1381428#M27159</guid>
      <dc:creator>JohnMcGlynn</dc:creator>
      <dc:date>2024-02-13T03:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS python HSV to RGB colour conversion</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1381993#M27163</link>
      <description>&lt;P&gt;I was able to fix this by using the algorithm at &lt;A href="https://www.rapidtables.com/convert/color/hsv-to-rgb.html" target="_self"&gt;rapidtables&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Unlike the data given in the ESRI documentation (hue = 0 - 240, saturation = 0 - 255, value = 0 - 255) the actual HSV format is hue 0 - 360, saturation 0 - 100, value 0 - 100&lt;/P&gt;&lt;P&gt;The code is now:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def colourHSVtoRGB(self,H,S,V):
        # The ArcGIS HSV model is - Hue 0-360, Saturation Pct, Value Pct
        # Algorithm from https://www.rapidtables.com/convert/color/hsv-to-rgb.html
        hval = H
        if hval == 360:
            hval = 0
        sval = S / 100
        vval = V / 100

        C = sval * vval
        tr = abs((hval / 60 % 2) - 1)
        X = C * (1 - tr)
        if 0 &amp;lt;= H and H &amp;lt; 60:
            R = C
            G = X
            B = 0
        elif 60 &amp;lt;= H and H &amp;lt; 120:
            R = X
            G = C
            B = 0
        elif 120 &amp;lt;= H and H &amp;lt; 180:
            R = 0
            G = C
            B = X
        elif 180 &amp;lt;= H and H &amp;lt; 240:
            R = 0
            G = X
            B = C
        elif 240 &amp;lt;= H and H &amp;lt; 300:
            R = X
            G = 0
            B = C
        elif 300 &amp;lt;= H and H &amp;lt; 360:
            R = C
            G = 0
            B = X

        m = vval - C
        R = int(round(255 * (R + m),0))
        G = int(round(255 * (G + m),0))
        B = int(round(255 * (B + m),0))

        return R, G, B&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;John&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 01:18:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1381993#M27163</guid>
      <dc:creator>JohnMcGlynn</dc:creator>
      <dc:date>2024-02-14T01:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS python HSV to RGB colour conversion</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1701007#M27726</link>
      <description>&lt;P&gt;Nice work! Thank you! You just saved me a mess of boring clicks.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2026 20:32:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcgis-python-hsv-to-rgb-colour-conversion/m-p/1701007#M27726</guid>
      <dc:creator>Jeff-Reinhart</dc:creator>
      <dc:date>2026-05-08T20:32:01Z</dc:date>
    </item>
  </channel>
</rss>

