<?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: How do I create and display the row and column of a hexagon grid in ArcGIS Mapping and Charting Questions</title>
    <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17371#M54</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh dear, mmm, I guess I did something wrong here... I used some code to create hexagons and analyzed the rows and columns to create the labels, but my hexagons are oriented differently... Oops. This is my result (I added the R and C to show what value represents the row and which one the column):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/115330_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I used is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import math
import arcpy
import os

&lt;SPAN&gt;# &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://stackoverflow.com/questions/26691097/faster-way-to-calculate-hexagon-grid-coordinates" target="_blank"&gt;http://stackoverflow.com/questions/26691097/faster-way-to-calculate-hexagon-grid-coordinates&lt;/A&gt;
def calc_polygons_new(startx, starty, endx, endy, radius):
&amp;nbsp;&amp;nbsp;&amp;nbsp; sl = (2 * radius) * math.tan(math.pi / 6)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # calculate coordinates of the hexagon points
&amp;nbsp;&amp;nbsp;&amp;nbsp; p = sl * 0.5
&amp;nbsp;&amp;nbsp;&amp;nbsp; b = sl * math.cos(math.radians(30))
&amp;nbsp;&amp;nbsp;&amp;nbsp; w = b * 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; h = 2 * sl

&amp;nbsp;&amp;nbsp;&amp;nbsp; # offsets for moving along and up rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; xoffset = b
&amp;nbsp;&amp;nbsp;&amp;nbsp; yoffset = 3 * p
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_xs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_xs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_ys = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_ys = []

&amp;nbsp;&amp;nbsp;&amp;nbsp; while startx &amp;lt; endx:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xs = [startx, startx, startx + b, startx + w, startx + w, startx + b, startx]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_xs.append(xs)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_xs.append([xoffset + x for x in xs])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startx += w

&amp;nbsp;&amp;nbsp;&amp;nbsp; while starty &amp;lt; endy:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ys = [starty + p, starty + (3 * p), starty + h, starty + (3 * p), starty + p, starty, starty + p]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (straight_ys if row % 2 else shifted_ys).append(ys)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; starty += yoffset
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row += 1

&amp;nbsp;&amp;nbsp;&amp;nbsp; polygons = [zip(xs, ys) for xs in shifted_xs for ys in shifted_ys] + [zip(xs, ys) for xs in straight_xs for ys in straight_ys]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return polygons

# create hexagons
result = calc_polygons_new(0, 0, 10, 10, 1)
cnt = 0
lst_x = []
lst_y = []
dct_hex = {}
for hexa in result:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for tpl in hexa:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = arcpy.Point(tpl[0], tpl[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst.append(pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = arcpy.Polygon(arcpy.Array(lst))
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = polygon.labelPoint.X
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = polygon.labelPoint.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_x.append(x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_y.append(y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_hex[cnt] = [polygon, x, y]

# sort x and y label points lists
lst_x = sorted(list(set(lst_x)))
lst_y = sorted(list(set(lst_y)))

# create column number
col = 0
dct_x = {}
for x in lst_x:
&amp;nbsp;&amp;nbsp;&amp;nbsp; col += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_x&lt;X&gt; = col&lt;/X&gt;

# create row number
row = 0
dct_y = {}
for y in reversed(lst_y):
&amp;nbsp;&amp;nbsp;&amp;nbsp; row += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_y&lt;Y&gt; = row&lt;/Y&gt;

# define label
for cnt, lst in dct_hex.items():
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = lst[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = lst[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = dct_y&lt;Y&gt;&lt;/Y&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; col = dct_x&lt;X&gt;&lt;/X&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; lbl = "C{0} R{1}".format("%02d" % (col,), "%02d" % (row,))
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst.append(lbl)
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_hex[cnt] = lst

# create empty fc
arcpy.env.overwriteOutput = True
out_fc = r"C:\Forum\Hexagon\hexa03.shp"
path, name = os.path.split(out_fc)
arcpy.CreateFeatureclass_management(path, name, "POLYGON")

# insert hexagons
fld_lbl = "Label"
arcpy.AddField_management(out_fc, fld_lbl, "TEXT", None, None, 10)
flds = ("SHAPE@", fld_lbl)
with arcpy.da.InsertCursor(out_fc, flds) as curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cnt, lst in dct_hex.items():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = (lst[0], lst[3],)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.insertRow(row)&lt;/PRE&gt;&lt;P&gt;I'm gonna dive into this again and generate the hexagons like you show in the image. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:42:00 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-10T20:42:00Z</dc:date>
    <item>
      <title>How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17370#M53</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how to make display coordinates of each hexagon in a hex array. The numbers are a combination of the row and column of the hexagon. The following is an example of what I'm trying to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;IMG alt="example.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/115313_example.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 22:47:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17370#M53</guid>
      <dc:creator>StephenRider</dc:creator>
      <dc:date>2015-07-02T22:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17371#M54</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh dear, mmm, I guess I did something wrong here... I used some code to create hexagons and analyzed the rows and columns to create the labels, but my hexagons are oriented differently... Oops. This is my result (I added the R and C to show what value represents the row and which one the column):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/115330_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I used is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import math
import arcpy
import os

&lt;SPAN&gt;# &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://stackoverflow.com/questions/26691097/faster-way-to-calculate-hexagon-grid-coordinates" target="_blank"&gt;http://stackoverflow.com/questions/26691097/faster-way-to-calculate-hexagon-grid-coordinates&lt;/A&gt;
def calc_polygons_new(startx, starty, endx, endy, radius):
&amp;nbsp;&amp;nbsp;&amp;nbsp; sl = (2 * radius) * math.tan(math.pi / 6)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # calculate coordinates of the hexagon points
&amp;nbsp;&amp;nbsp;&amp;nbsp; p = sl * 0.5
&amp;nbsp;&amp;nbsp;&amp;nbsp; b = sl * math.cos(math.radians(30))
&amp;nbsp;&amp;nbsp;&amp;nbsp; w = b * 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; h = 2 * sl

&amp;nbsp;&amp;nbsp;&amp;nbsp; # offsets for moving along and up rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; xoffset = b
&amp;nbsp;&amp;nbsp;&amp;nbsp; yoffset = 3 * p
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_xs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_xs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_ys = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_ys = []

&amp;nbsp;&amp;nbsp;&amp;nbsp; while startx &amp;lt; endx:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xs = [startx, startx, startx + b, startx + w, startx + w, startx + b, startx]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; straight_xs.append(xs)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shifted_xs.append([xoffset + x for x in xs])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startx += w

&amp;nbsp;&amp;nbsp;&amp;nbsp; while starty &amp;lt; endy:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ys = [starty + p, starty + (3 * p), starty + h, starty + (3 * p), starty + p, starty, starty + p]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (straight_ys if row % 2 else shifted_ys).append(ys)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; starty += yoffset
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row += 1

&amp;nbsp;&amp;nbsp;&amp;nbsp; polygons = [zip(xs, ys) for xs in shifted_xs for ys in shifted_ys] + [zip(xs, ys) for xs in straight_xs for ys in straight_ys]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return polygons

# create hexagons
result = calc_polygons_new(0, 0, 10, 10, 1)
cnt = 0
lst_x = []
lst_y = []
dct_hex = {}
for hexa in result:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for tpl in hexa:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = arcpy.Point(tpl[0], tpl[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst.append(pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = arcpy.Polygon(arcpy.Array(lst))
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = polygon.labelPoint.X
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = polygon.labelPoint.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_x.append(x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_y.append(y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_hex[cnt] = [polygon, x, y]

# sort x and y label points lists
lst_x = sorted(list(set(lst_x)))
lst_y = sorted(list(set(lst_y)))

# create column number
col = 0
dct_x = {}
for x in lst_x:
&amp;nbsp;&amp;nbsp;&amp;nbsp; col += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_x&lt;X&gt; = col&lt;/X&gt;

# create row number
row = 0
dct_y = {}
for y in reversed(lst_y):
&amp;nbsp;&amp;nbsp;&amp;nbsp; row += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_y&lt;Y&gt; = row&lt;/Y&gt;

# define label
for cnt, lst in dct_hex.items():
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = lst[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = lst[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = dct_y&lt;Y&gt;&lt;/Y&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; col = dct_x&lt;X&gt;&lt;/X&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; lbl = "C{0} R{1}".format("%02d" % (col,), "%02d" % (row,))
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst.append(lbl)
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_hex[cnt] = lst

# create empty fc
arcpy.env.overwriteOutput = True
out_fc = r"C:\Forum\Hexagon\hexa03.shp"
path, name = os.path.split(out_fc)
arcpy.CreateFeatureclass_management(path, name, "POLYGON")

# insert hexagons
fld_lbl = "Label"
arcpy.AddField_management(out_fc, fld_lbl, "TEXT", None, None, 10)
flds = ("SHAPE@", fld_lbl)
with arcpy.da.InsertCursor(out_fc, flds) as curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cnt, lst in dct_hex.items():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = (lst[0], lst[3],)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.insertRow(row)&lt;/PRE&gt;&lt;P&gt;I'm gonna dive into this again and generate the hexagons like you show in the image. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:42:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17371#M54</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T20:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17372#M55</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xander there are two representations of hexagons...pointy-headed and flat-headed (and they aren't my terms).&amp;nbsp; I document both on my blog:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/2519"&gt;Numpy Snippets # 3 ... Phish_Nyet ... creating sampling grids using numpy and arcpy&lt;/A&gt; &lt;STRONG&gt; and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;A href="https://community.esri.com/migration-blogpost/37531"&gt;NumPy Snippets # 4... N-gons... Regular polygonal shape generation&lt;/A&gt; . &lt;/P&gt;&lt;P&gt;One of them has some code for numbering but it is different than the method you used, to give some options.&lt;/P&gt;&lt;P&gt;So pick your type and number accordingly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 01:09:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17372#M55</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-03T01:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17373#M56</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, a second test looks like this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/115334_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;... and applying the label format from your example:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/115335_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I used for this was:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import math
import arcpy
import os

def generate_hexagons(startx, starty, endx, endy, radius):
&amp;nbsp;&amp;nbsp;&amp;nbsp; hex_h = math.sin(math.radians(60)) * radius * 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; hex_w = radius + math.cos(math.radians(60)) * radius
&amp;nbsp;&amp;nbsp;&amp;nbsp; cols = int(math.ceil((endx - startx) / hex_w))
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = int(math.ceil((endy - starty) / hex_h))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct = {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for col in range(cols):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in range(rows):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = startx + (col * hex_w)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = endy - (row * hex_h)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m = col % 2 == 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = create_hexagon(x, y, radius, m)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct[cnt] = [polygon, col+1, row+1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return dct

def create_hexagon(x, y, radius, shift):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; shift_y = -1 * (math.sin(math.radians(60)) * radius) if shift else 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for a in range(7):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle = a * 60
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst.append(arcpy.Point(x + math.cos(math.radians(angle)) * radius, y + math.sin(math.radians(angle)) * radius + shift_y))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return arcpy.Polygon(arcpy.Array(lst))

# create empty fc
arcpy.env.overwriteOutput = True
out_fc = r"C:\Forum\Hexagon\hexa2v05.shp"
path, name = os.path.split(out_fc)
arcpy.CreateFeatureclass_management(path, name, "POLYGON")

# generate the hexagons from 0,0 to 10,10 with a radius of 1
dct = generate_hexagons(0, 0, 10, 10, 1)

# write the hexagons to a fc
fld_lbl = "Label"
arcpy.AddField_management(out_fc, fld_lbl, "TEXT", None, None, 10)
flds = ("SHAPE@", fld_lbl)
with arcpy.da.InsertCursor(out_fc, flds) as curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cnt, lst in dct.items():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = lst[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col = lst[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = lst[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # lbl = "C{0} R{1}".format("%02d" % (col,), "%02d" % (row,))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lbl = "{0}{1}".format("%02d" % (col,), "%02d" % (row,))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = (polygon, lbl,)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.insertRow(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have any questions let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:42:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17373#M56</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T20:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17374#M57</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt; , thanks for reminding me of what numpy is capable. Great links!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 01:46:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17374#M57</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-07-03T01:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17375#M58</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;... and if you want to use the cloud: &lt;A href="http://blogs.esri.com/esri/arcgis/2015/08/26/creating-thematic-maps-with-hexagons-in-arcgis-online/" title="http://blogs.esri.com/esri/arcgis/2015/08/26/creating-thematic-maps-with-hexagons-in-arcgis-online/"&gt;Creating thematic maps with hexagons in ArcGIS Online | ArcGIS Blog&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 11:37:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17375#M58</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-08-27T11:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create and display the row and column of a hexagon grid</title>
      <link>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17376#M59</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice!!! Hexagons are where its at &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 15:42:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-mapping-and-charting-questions/how-do-i-create-and-display-the-row-and-column-of/m-p/17376#M59</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-27T15:42:52Z</dc:date>
    </item>
  </channel>
</rss>

