<?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 user defined spatial reference in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188631#M64879</link>
    <description>&lt;P&gt;See my comment below on what happens when i try and hard code a coordinate system&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2022 09:54:20 GMT</pubDate>
    <dc:creator>MichaelFowler1</dc:creator>
    <dc:date>2022-07-01T09:54:20Z</dc:date>
    <item>
      <title>Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1187704#M64853</link>
      <description>&lt;P&gt;Hi All!!&lt;/P&gt;&lt;P&gt;So I'm currently writing a script that will allow end users to create a map, and the only hiccup I'm having is the spatial reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the below code I receive the below error. But since its the generic error I'm not too sure what's going wrong.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(arcpy.GetParameterAsText(3))

RuntimeError:  ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;In the toolbox I have the data type set as 'Coordinate System'.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 10:20:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1187704#M64853</guid>
      <dc:creator>MichaelFowler1</dc:creator>
      <dc:date>2022-06-29T10:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1187763#M64855</link>
      <description>&lt;P&gt;It could be something else in your script, if there is more to it so step through it with the debugger.&lt;/P&gt;&lt;P&gt;If the error is on this part, what is getting past as in the GetParameterAsText? SpatialReference accepts the projection (.prj), the name of the projection as text ("Hawaii Albers Equal Area Conic") or the spatial reference's factory code (32145) but not '32145'.&amp;nbsp; Does it work if the inputs are hardcoded?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(32145)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 13:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1187763#M64855</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-06-29T13:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188061#M64866</link>
      <description>&lt;P&gt;Use the SpatialReference or CoordinateSystem objects directly (i.e. use arcpy.GetParameter instead of GetParameterAsText)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Luke_Pinner_0-1656536305023.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/44831iA61D0448F61A77BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Luke_Pinner_0-1656536305023.png" alt="Luke_Pinner_0-1656536305023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#This works
sr = arcpy.GetParameter(0)
arcpy.env.outputCoordinateSystem = sr

#So does this
crs = arcpy.GetParameter(1)
arcpy.env.outputCoordinateSystem = crs&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 21:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188061#M64866</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-06-29T21:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188630#M64878</link>
      <description>&lt;P&gt;I have tried both the above methods and its still not working for me.&lt;/P&gt;&lt;P&gt;So i have tried running a hard coded test in the python window:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;crs = 'WGS 1984'
arcpy.env.outputCoordinateSystem = crs

RuntimeError: Object: Error in accessing environment &amp;lt;outputCoordinateSystem&amp;gt;

utm = 'WGS 1984 UTM Zone 56S'
arcpy.env.outputCoordinateSystem = utm

RuntimeError: Object: Error in accessing environment &amp;lt;outputCoordinateSystem&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would this be because of a part earlier in my script?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 09:53:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188630#M64878</guid>
      <dc:creator>MichaelFowler1</dc:creator>
      <dc:date>2022-07-01T09:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188631#M64879</link>
      <description>&lt;P&gt;See my comment below on what happens when i try and hard code a coordinate system&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 09:54:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188631#M64879</guid>
      <dc:creator>MichaelFowler1</dc:creator>
      <dc:date>2022-07-01T09:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy user defined spatial reference</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188633#M64880</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/49147"&gt;@MichaelFowler1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I have tried both the above methods and its still not working for me.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Weird, works fine for me.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/49147"&gt;@MichaelFowler1&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;crs = 'WGS 1984'
arcpy.env.outputCoordinateSystem = crs

RuntimeError: Object: Error in accessing environment &amp;lt;outputCoordinateSystem&amp;gt;

utm = 'WGS 1984 UTM Zone 56S'
arcpy.env.outputCoordinateSystem = utm

RuntimeError: Object: Error in accessing environment &amp;lt;outputCoordinateSystem&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to hardcode a spatial reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;crs = arcpy.SpatialReference(4326) # 'WGS 1984' https://epsg.io/4326
arcpy.env.outputCoordinateSystem = crs

utm = arcpy.SpatialReference(32756) # 'WGS 1984 UTM Zone 56S' https://epsg.io/32756
arcpy.env.outputCoordinateSystem = utm&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 10:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-user-defined-spatial-reference/m-p/1188633#M64880</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-07-01T10:05:26Z</dc:date>
    </item>
  </channel>
</rss>

