<?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: Arcpy -- Edit Spatial Reference Object Properties in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272870#M21097</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running into a problem with the version of this script making use of DefineProjection.&amp;nbsp; I'm getting an error indicating a problem executing the tool (see screenshot).&amp;nbsp; FYI, I'm using 10.2.2 and Python 2.7 on a Windows 7 64-bit system.&amp;nbsp; I've also uploaded my test data folder, in case anyone wants to take a look at it.&amp;nbsp; Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Trill&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/140839_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;existing code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

def recursiveProjections(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function iterates through a workspace and its subfolders using arcpy.da.walk and returns
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a tuple containing two lists: 1) list of spatial reference objects of all geographic datasets (including those inside
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geodatabases) and 2) a list of filepaths for the geographic datasets.&amp;nbsp; Parameter: target workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; describeDatasets = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; filesList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, path, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; describeDatasets.append(desc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for path, path_names, data_names in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for data_name in data_names:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filesList.append(os.path.join(path, data_name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return describeDatasets, filesList


def defineProjection(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function redefines the existing projection for datasets in a workspace.&amp;nbsp; A log file is created listing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the paths of all redefined datasets.&amp;nbsp; Parameter: workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; # unpack tuple returned by def recursiveProjections into two lists
&amp;nbsp;&amp;nbsp;&amp;nbsp; descriptions, filenames = recursiveProjections(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through features and redefine their projections correctly
&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in descriptions:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DefineProjection_management(feature, newProjection)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # logging
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print filename


def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; defineProjection(workspace)


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:19:40 GMT</pubDate>
    <dc:creator>TrilliumLevine1</dc:creator>
    <dc:date>2021-12-11T13:19:40Z</dc:date>
    <item>
      <title>Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272861#M21088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to develop a python script&amp;nbsp; to edit the name property of several spatial reference objects found while iterating through a folder and its subdirectories.&amp;nbsp; The projection of the data is identical to ETRS_1989_UTM_Zone_32N, but is named something else -- I'm just trying to reset the name to ETRS_1989_UTM_Zone_32N.&amp;nbsp; According to the help, this property is both readable and writable in ArcGIS 10.2, which is what I'm running.&amp;nbsp; I'm just not sure how to go about writing in the new projection name via the script...anybody have any ideas?&amp;nbsp; Any feedback is greaty appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

workspace = r"C:\Scripts\Reproject"
newProjection = "ETRS_1989_UTM_Zone_32N"

def recursiveProjections(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; Function iterates through a workspace and its subfolders using arcpy.da.walk and returns
&amp;nbsp;&amp;nbsp;&amp;nbsp; a list of spatial reference objects of all geographic datasets (including those inside
&amp;nbsp;&amp;nbsp;&amp;nbsp; geodatabases).&amp;nbsp; Parameter: target workspace

&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; projections = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srObject = desc.spatialReference
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projections.append(srObject)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return projections

def editProjection(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; projections = recursiveProjections(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for projection in projections:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print projection.name

editProjection(workspace)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272861#M21088</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272862#M21089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Trillium,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps the 'Define Projection' tool (&lt;A href="http://resources.arcgis.com/en/help/main/10.2/#/Define_Projection/001700000077000000/" title="http://resources.arcgis.com/en/help/main/10.2/#/Define_Projection/001700000077000000/"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; ) is what you're after?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand you correctly, you want to walk over all the feature classes in a workspace and change the Spatial Reference for each one to ETRS_1989_UTM_Zone_32N. 'Define Projection' should enable you to do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 13:20:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272862#M21089</guid>
      <dc:creator>AndrewLowerre</dc:creator>
      <dc:date>2015-11-05T13:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272863#M21090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response, but that won't work since (as far as I know) you can't define a projection for something that already has one defined.&amp;nbsp; Anyway, I figured out how to do it in code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

workspace = r"C:\Scripts\Reproject"
newProjection = "PROJCS['ETRS_1989_UTM_Zone_32N'"

def recursiveProjections(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; Function iterates through a workspace and its subfolders using arcpy.da.walk and returns
&amp;nbsp;&amp;nbsp;&amp;nbsp; a list of spatial reference objects of all geographic datasets (including those inside
&amp;nbsp;&amp;nbsp;&amp;nbsp; geodatabases).&amp;nbsp; Parameter: target workspace

&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; projections = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srObject = desc.spatialReference
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projections.append(srObject)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return projections

def editProjection(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; projections = recursiveProjections(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for projection in projections:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projectionParameters = projection.exportToString()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterSplit = projectionParameters.split(",")
##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print parameterSplit[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterSplit[0] = newProjection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SR_outstring = ",".join(parameterSplit)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print SR_outstring

editProjection(workspace)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272863#M21090</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272864#M21091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a note about &lt;A href="https://community.esri.com/migrated-users/49904"&gt;Andrew Lowerre&lt;/A&gt;​'s suggestion for Define Projection. The general wisdom is that you &lt;EM&gt;shouldn't&lt;/EM&gt; use Define once a CRS has been defined, because you have correctly defined the CRS in the first place. In this case, you have "incorrectly" (on purpose) defined your CRS with the "wrong" name. It is perfectly reasonable to use Define to change the name. I suspect your script mirrors the Define tool - it would be interesting to see the run time comparison.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272864#M21091</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-11-05T17:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272865#M21092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was my understanding as well, but since Trillium seemed to have found something that worked, I figured case closed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 09:34:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272865#M21092</guid>
      <dc:creator>AndrewLowerre</dc:creator>
      <dc:date>2015-11-06T09:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272866#M21093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feeling that the correct way would be just to set the projection using Define.&lt;/P&gt;&lt;P&gt;In the code above I cannot see how the actual projection is redefined. It just changes the "Name" part of the projection text representation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 13:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272866#M21093</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-11-06T13:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272867#M21094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/5327"&gt;Neil Ayres&lt;/A&gt;​, the code does exactly what you suggest, renaming a known projection, essentially creating a "custom" projection. The equivalent using Define would be to create a custom projection beforehand and define to that. Six one way, half dozen the other (although actual performance may differ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 19:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272867#M21094</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-11-06T19:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272868#M21095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well exactly. So wouldn't the sr remain a custom one?&lt;/P&gt;&lt;P&gt;Far better just to do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sr = arcpy.SpatialReference(25832) # wkid for 'ETRS_1989_UTM_Zone_32N'
&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;DefineProjection_management&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;infc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sr&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;And you can define the sr for a feature class that already has one. With certain caveats of course, don't define the fc as something it isn't...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272868#M21095</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-11T13:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272869#M21096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all the feedback, everyone -- looks like Neil's answer will keep the simplest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 07:29:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272869#M21096</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2015-11-10T07:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272870#M21097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running into a problem with the version of this script making use of DefineProjection.&amp;nbsp; I'm getting an error indicating a problem executing the tool (see screenshot).&amp;nbsp; FYI, I'm using 10.2.2 and Python 2.7 on a Windows 7 64-bit system.&amp;nbsp; I've also uploaded my test data folder, in case anyone wants to take a look at it.&amp;nbsp; Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Trill&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/140839_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;existing code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

def recursiveProjections(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function iterates through a workspace and its subfolders using arcpy.da.walk and returns
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a tuple containing two lists: 1) list of spatial reference objects of all geographic datasets (including those inside
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geodatabases) and 2) a list of filepaths for the geographic datasets.&amp;nbsp; Parameter: target workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; describeDatasets = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; filesList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, path, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; describeDatasets.append(desc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for path, path_names, data_names in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for data_name in data_names:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filesList.append(os.path.join(path, data_name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return describeDatasets, filesList


def defineProjection(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function redefines the existing projection for datasets in a workspace.&amp;nbsp; A log file is created listing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the paths of all redefined datasets.&amp;nbsp; Parameter: workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; # unpack tuple returned by def recursiveProjections into two lists
&amp;nbsp;&amp;nbsp;&amp;nbsp; descriptions, filenames = recursiveProjections(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through features and redefine their projections correctly
&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in descriptions:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DefineProjection_management(feature, newProjection)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # logging
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print filename


def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; defineProjection(workspace)


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272870#M21097</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272871#M21098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;where is newprojection defined? it isn't passed to your function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 11:53:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272871#M21098</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-10T11:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272872#M21099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oops, it didn't get pasted in -- it and the workspace are defined as a global variables after the import statements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;workspace = r"C:\Scripts\Reproject"
newProjection = arcpy.SpatialReference(25832) # wkid for 'ETRS_1989_UTM_Zone_32N'&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272872#M21099</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272873#M21100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps of note is that my directory contains a geodatabase, with a feature dataset composed of feature classes.&amp;nbsp; According to the help for the define projection tool, once a feature dataset contains feature classes, its projection cannot be changed.&amp;nbsp; Even after removing the geodatabase from my test directory, however, the script still generates the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 12:53:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272873#M21100</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2015-11-10T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272874#M21101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the long delay, been away at the esri Africa UC...&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Yes, if you have a pile of Fc's inside a fd, the SR is defined at the fd level. You can only change it by copying out the fc to another fd or using the project tool (and putting the output somewhere else).&lt;/P&gt;&lt;P&gt;Not sure what the error is, but instead of redefining each fc did you try to redefine just the sr of the fd?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2015 16:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272874#M21101</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-11-16T16:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272875#M21102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the delay, I was just now able to try Neil's sollution. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the Help: All feature classes in a geodatabase feature dataset will be in the same coordinate system. &lt;STRONG&gt;The coordinate system for a geodatabase dataset should be determined when it is created. Once it contains feature classes, its coordinate system cannot be changed.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is &lt;STRONG&gt;not&lt;/STRONG&gt; the case, however -- a feature dataset &lt;STRONG&gt;can&lt;/STRONG&gt; indeed be redefined if it already contains feature classes (which will also be redefined along with the FD).&amp;nbsp; The redefine tool simply generates a warning, but it still works.&amp;nbsp; ESRI needs to update their help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Dec 2015 11:00:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272875#M21102</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2015-12-03T11:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272876#M21103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have a workable sollution to this based on everyone's feedback (see code below).&amp;nbsp; The only nagging issue is that when I run recursiveDatasets in main() after redefining all feature classes and datasets, when I print spatialReference.name, it's still printing the old spatial reference&amp;nbsp; I checked the SR in ArcCatalog for each FC and FD, and they have indeed been redefined:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/151534_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So why is it still printing the old SR?&amp;nbsp; Is that output being drawn from a different parameter than that being displayed in the XY Coordinate System tab?&amp;nbsp; I have also tried refreshing the geodatabase following the redefinition, but that makes no difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# -*- coding: utf-8 -*-

import os
from os import path
import arcpy
from arcpy import env
from sets import Set
import time, datetime
from datetime import date

arcpy.env.overwriteOutput = True

def recursiveDatasets(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function iterates through a file geodatabase using arcpy.da.walk and returns a tuple
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; containing three lists: 1) uniqueFD, containing paths to each feature dataset in the geodatabase;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) miscDatasets, containing all feature classes in a geodatabase not inside a feature dataset;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3) descriptions, containing description objects for every feature class and feature dataset in
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the target geodatabase.&amp;nbsp; Parameter: Workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; miscDatasets = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureDatasets = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; descriptions = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, path, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hasattr(desc, 'path'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; descPth = arcpy.Describe(desc.path)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; descriptions.append(desc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hasattr(descPth, 'dataType'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if descPth.dataType == 'FeatureDataset':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureDatasets.append(dirpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; miscDatasets.append(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniqueFD = list(set(featureDatasets))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return uniqueFD, miscDatasets, descriptions


def defineProjection(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function redefines the existing projection for feature datasets and feature classes not residing in feature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datasets in a geodatabase.&amp;nbsp; Parameter: workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniqueFD, miscDatasets, descriptions = recursiveDatasets(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for FC in miscDatasets:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(FC)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if desc.datasetType == 'FeatureClass':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DefineProjection_management(FC, newProjection)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for FD in uniqueFD:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DefineProjection_management(FD, newProjection)


def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace = arcpy.env.workspace = os.path.join(r'C:\Scripts\Redefine Projection\MyGeodatabase.gdb')
&amp;nbsp;&amp;nbsp;&amp;nbsp; newProjection = arcpy.SpatialReference(25832) # wkid for 'ETRS_1989_UTM_Zone_32N'
&amp;nbsp;&amp;nbsp;&amp;nbsp; defineProjection(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniqueFD, miscDatasets, newDescriptions = recursiveDatasets(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; FCs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; newSRs = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dataset in newDescriptions:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dataset.datasetType == 'FeatureClass':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCs.append(os.path.join(dataset.Path, dataset.Name))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newSRs.append(dataset.spatialReference.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print newSRs


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272876#M21103</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272877#M21104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the same problem.&amp;nbsp; The dataset and feature classes seem to be changed, but the desc.spatialReference.name ist still named as the old spatial reference.&lt;/P&gt;&lt;P&gt;After copying the dataset in a new geodatabase, the desc.spatialReference.name ist correct and consistent.&lt;/P&gt;&lt;P&gt;Is there a solution/workround (without copying)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 16:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272877#M21104</guid>
      <dc:creator>MarcoDellenbach</dc:creator>
      <dc:date>2016-03-14T16:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy -- Edit Spatial Reference Object Properties</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272878#M21105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;Sorry for the late answer, here's what I ended up with that works, hope it's helpful -- does a bit of logging for you too:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# -*- coding: utf-8 -*-
import os
from os import path
import arcpy
from arcpy import env
from sets import Set
import time, datetime
from datetime import date

arcpy.env.overwriteOutput = True
newProjection = arcpy.SpatialReference(25832) # wkid for 'ETRS_1989_UTM_Zone_32N'

# ################### #
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FUNCTIONS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
# ################### #

def recursiveDatasets(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; Function iterates through a workspace and its subfolders using arcpy.da.walk and returns
&amp;nbsp;&amp;nbsp;&amp;nbsp; a list of spatial reference objects of all geographic datasets (including those inside
&amp;nbsp;&amp;nbsp;&amp;nbsp; geodatabases).&amp;nbsp; Parameter: target workspace

&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; paths = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniquePaths = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in arcpy.da.Walk(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hasattr(desc, 'path'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; descPth = arcpy.Describe(desc.path)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hasattr(descPth, 'dataType'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # return list of FD paths and FC paths not in FD's
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if descPth.dataType == 'FeatureDataset':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; paths.append(dirpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif desc.datasetType == 'FeatureClass':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; paths.append(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # make list without duplicates
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniquePaths = list(set(paths))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return uniquePaths


def defineProjection(workspace, toRedefine):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function redefines datasets in a given projection in a geodatabase.&amp;nbsp; Parameters: workspace, projection to consider
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; paths = recursiveDatasets(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for path in paths:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create a description object for every dataset (incl. tables, relationship classes) not residing in FD
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(path)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if desc.spatialReference.Name == toRedefine:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.DefineProjection(desc.Name, newProjection)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print desc.Name + ' wurde neu definiert.'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print desc.Name + ' wurde nicht neu definiert.'



def Logging(myLog, writeFormat, runDate, headers, list1, list2, colWdth):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ Function will generates a log file composed of two columns (list1 and list2) with defined
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; headers and date of execution. Parameters: full log filepath, write format, date of execution,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; headers, list1, list2, column width
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(myLog, writeFormat) as myLog:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLog.write(runDate)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLog.write(headers)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in zip(list1, list2):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLog.write(colWdth.format(*item))


# ################# #
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
# ################# #

def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Processing geodatabase...'
&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace = arcpy.env.workspace = r'C:\Scripts\Redefine_Projection\Thomas\2016-01-25_GeoDB03_gd_Export.gdb'

&amp;nbsp;&amp;nbsp;&amp;nbsp; toRedefine = 'ETRS_1989_UTM_Zone_32N_6stellen'
&amp;nbsp;&amp;nbsp;&amp;nbsp; defineProjection(workspace, toRedefine)
&amp;nbsp;&amp;nbsp;&amp;nbsp; datasets = recursiveDatasets(workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Logging results...'
&amp;nbsp;&amp;nbsp;&amp;nbsp; # list of projections
&amp;nbsp;&amp;nbsp;&amp;nbsp; projections = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dataset in datasets:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(dataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projections.append(desc.spatialReference.Name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # logging
&amp;nbsp;&amp;nbsp;&amp;nbsp; myLog = r"C:\Scripts\Redefine_Projection\Log\RedefineProjection.log"
&amp;nbsp;&amp;nbsp;&amp;nbsp; today = date.today()
&amp;nbsp;&amp;nbsp;&amp;nbsp; runDate = 'Tag der Durchführung: ' + today.strftime("%Y.%m.%d") + '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; # first column header is 'Feature Class' justified left w/125 character buffer before 'Neue Spatial Reference' header
&amp;nbsp;&amp;nbsp;&amp;nbsp; headers = '{0: &amp;lt;125}'.format('Pfad der Datensatz') + 'Spatial Reference' + '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; colWdth ="{:&amp;lt;125}"*2 + "\n"&amp;nbsp;&amp;nbsp; # 2 columns with 125 character width
&amp;nbsp;&amp;nbsp;&amp;nbsp; Logging(myLog, 'a', runDate, headers, datasets, projections, colWdth)


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-edit-spatial-reference-object-properties/m-p/272878#M21105</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2021-12-11T13:19:49Z</dc:date>
    </item>
  </channel>
</rss>

