<?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: Rename Feature Classes Based on Polygon Index Attributes in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1275965#M44498</link>
    <description>&lt;P&gt;Are the lines in their own FGDB separate from the index polygon, what's the layout of the data - is there anhything else in that FGDB?&amp;nbsp; If you iterated through that workspace it would only return the line FCs?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 19:46:56 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2023-04-05T19:46:56Z</dc:date>
    <item>
      <title>Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1275879#M44497</link>
      <description>&lt;P&gt;I have a file gdb containing the following items, and I am using version 10.8.2&lt;/P&gt;&lt;P&gt;200 line feature classes currently named Contour_Tile1, Contour_Tile2, etc...&lt;/P&gt;&lt;P&gt;I also have a single polygon feature class named Index_5000ft.&amp;nbsp; It contains 200 polygons (one bounding polygon for each of the previously mentioned line feature classes).&amp;nbsp; In the polygon attribute table there is a column named [Tile_Num] and it contains values like GAW_30310026.&amp;nbsp; There is no correlation between the name of the line feature class, and the polygon that it might fall within.&amp;nbsp; For example, all the lines in the Contour_Tile1 FC, might fall inside an index polygon with the attribute of GAW_30310026.&amp;nbsp; The only thing they have in common is their spatial relationship (extent).&lt;/P&gt;&lt;P&gt;Lines contained within any one of the line feature classes, will always fall completely within a single polygon found in the Index_5000ft FC.&amp;nbsp; Lines from a single FC will never intersect with more than one index polygon.&lt;/P&gt;&lt;P&gt;What I want to do is rename each of the line feature classes from Contour_Tile1, to something like GAW_30310026, which is found in the [Tile_Num] column of the corresponding polygon attribute table.&lt;/P&gt;&lt;P&gt;FYI: Right now I'm only having to deal with 200 tiles, but I will need to repeat this process many more times, so "automation" is the only way I can make this work.&amp;nbsp; In other words, I can't resort to manual renaming because I will have many thousands of FCs to deal with.&amp;nbsp; Does anyone have any ideas on how to rename the line FCs, as described here?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 17:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1275879#M44497</guid>
      <dc:creator>ChadR</dc:creator>
      <dc:date>2023-04-05T17:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1275965#M44498</link>
      <description>&lt;P&gt;Are the lines in their own FGDB separate from the index polygon, what's the layout of the data - is there anhything else in that FGDB?&amp;nbsp; If you iterated through that workspace it would only return the line FCs?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 19:46:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1275965#M44498</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-04-05T19:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276001#M44499</link>
      <description>&lt;P&gt;Obviously try it on a copy and/or subset of your data first (and keep a backup of the original for some time regardless)&amp;nbsp; also close down arcmap etc to get rid of any locks for renaming:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

index_fc = r'C:\ArcGIS\yourFGDBgdb\Your index polygons'
line_gdb = r'C:\ArcGIS\FGDB containing your lines.gdb'


#list the fc names and paths to line FCs
arcpy.env.workspace = line_gdb
lines_fclist = [[fc, os.path.join(line_gdb, fc)] for fc in arcpy.ListFeatureClasses(feature_type="line")]


#create a list to store FC name and
#single line geom from each lines FC
linefc_list=[]
for line_fc in lines_fclist:
    with arcpy.da.SearchCursor(line_fc[1],["SHAPE@"]) as cursor:
        for row in cursor:
            linefc_list.append([line_fc[0],row[0]])
            break


#create a dictionary of line fc path and intersecting index polygon name
index_line_dict = {}
with arcpy.da.SearchCursor(index_fc,[“Tile_Num","SHAPE@"]) as cursor:
    for row in cursor:
        for line in linefc_list:
            if row[1].disjoint(line[1]) is False:
                index_line_dict[os.path.join(line_gdb, line[0])] = row[0]
                break

print(index_line_dict)

#rename lines to match
for filepath in index_line_dict:
    arcpy.management.Rename(filepath,index_line_dict[filepath],"FeatureClass")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 21:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276001#M44499</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-04-05T21:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276032#M44500</link>
      <description>&lt;P&gt;I will give this a shot tomorrow and let you know how it goes.&amp;nbsp; Thank you very much for responding!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 23:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276032#M44500</guid>
      <dc:creator>ChadR</dc:creator>
      <dc:date>2023-04-05T23:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276033#M44501</link>
      <description>&lt;P&gt;Right now the 200 line FCs and the one Index polygon FC are in the same FGDB, but I can easily move the index polygon FC to its on FGDB, so an iterator would only see the line FCs.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 23:25:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276033#M44501</guid>
      <dc:creator>ChadR</dc:creator>
      <dc:date>2023-04-05T23:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Feature Classes Based on Polygon Index Attributes</title>
      <link>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276174#M44502</link>
      <description>&lt;P&gt;David - that did the trick.&amp;nbsp; You're awesome!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 14:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/rename-feature-classes-based-on-polygon-index/m-p/1276174#M44502</guid>
      <dc:creator>ChadR</dc:creator>
      <dc:date>2023-04-06T14:53:10Z</dc:date>
    </item>
  </channel>
</rss>

