<?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 Script tool to assign projection across all maps within a project in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684763#M101939</link>
    <description>&lt;P&gt;Hi, that worked! I knew it was an easy fix, thanks for pointing me in the right direction &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Feb 2026 17:11:14 GMT</pubDate>
    <dc:creator>MadelineP</dc:creator>
    <dc:date>2026-02-17T17:11:14Z</dc:date>
    <item>
      <title>Arcpy Script tool to assign projection across all maps within a project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684621#M101926</link>
      <description>&lt;P&gt;Hi everyone. I am attempting to create a script tool that assigns a coordinate system across all maps within a Pro project. The purpose of this is to avoid having to assign each projection manually after creating a new map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I first wrote out the code with hard-coded variables, which runs perfectly:&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Reference the current project&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;# Define the target coordinate system (use a WKID or Name)&lt;BR /&gt;# Example: 4326 is WGS 1984&lt;BR /&gt;new_sr = arcpy.SpatialReference(2285)&lt;/P&gt;&lt;P&gt;# Loop through all maps in the project&lt;BR /&gt;for map_obj in aprx.listMaps():&lt;BR /&gt;# Assign the new spatial reference to the map&lt;BR /&gt;map_obj.spatialReference = new_sr&lt;BR /&gt;print(f"Updated projection for map: {map_obj.name}")&lt;/P&gt;&lt;P&gt;# Save the project to commit changes&lt;BR /&gt;aprx.save()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the altered code I created to insert inside the Script tool:&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;&lt;BR /&gt;# Get the SpatialReference object directly from the tool parameter&lt;BR /&gt;spatial_ref = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;# Iterate through maps&lt;BR /&gt;for map_object in aprx.listMaps():&lt;BR /&gt;map_object.spatialReference = spatial_ref&amp;nbsp;&lt;BR /&gt;arcpy.AddMessage(f"Updated projection for: {map_object.name}")&lt;BR /&gt;&lt;BR /&gt;# Save once after all updates are complete&lt;BR /&gt;aprx.save()&lt;BR /&gt;arcpy.AddMessage("All maps updated and project saved.")&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt;arcpy.AddError(f"Error assigning coordinate systems: {str(e)}")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the script, I am prompted to select a coordinate system, which is exactly what I want. However, when I run the script, it fails with the error message&amp;nbsp;&lt;STRONG&gt;Error assigning coordinate systems: SpatialReference: Input value is not valid.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;These are my parameters within the script.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MadelineP_0-1771300216914.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/148474iA87DBE11178D9C8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MadelineP_0-1771300216914.png" alt="MadelineP_0-1771300216914.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that it's something related to the coordinate system input parameter, I just can't figure out what. FYI I am a beginner to coding/making script tools so please give me advice in layman's terms &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; TIA!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 03:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684621#M101926</guid>
      <dc:creator>MadelineP</dc:creator>
      <dc:date>2026-02-17T03:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy Script tool to assign projection across all maps within a project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684658#M101930</link>
      <description>&lt;P&gt;There is a "Spatial Reference" under the Data Type drop down... did you try it&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 11:01:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684658#M101930</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2026-02-17T11:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy Script tool to assign projection across all maps within a project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684763#M101939</link>
      <description>&lt;P&gt;Hi, that worked! I knew it was an easy fix, thanks for pointing me in the right direction &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 17:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-tool-to-assign-projection-across-all/m-p/1684763#M101939</guid>
      <dc:creator>MadelineP</dc:creator>
      <dc:date>2026-02-17T17:11:14Z</dc:date>
    </item>
  </channel>
</rss>

