<?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: Problem with changing Spatial Reference of data frame using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532589#M41725</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also pipe in a WKID code in replace of a prjFile like &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;sr = arcpy.SpatialReference(3857) which is the Web Mercator Projection to bypass that project file step.&amp;nbsp; Also I got hung up on the df.spatialReference = sr .....I capitalized Spatial as some help articles on ESRI reference it that way.&amp;nbsp; Thanks for the clear exacting code! It helped me stop pulling my hair out.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jun 2016 20:55:04 GMT</pubDate>
    <dc:creator>DylanKennard</dc:creator>
    <dc:date>2016-06-03T20:55:04Z</dc:date>
    <item>
      <title>Problem with changing Spatial Reference of data frame using Python</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532586#M41722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Hi-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to understand how to change the coordinate system of a data frame using python. I have tried the following code but itdoesn't seem to work:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;import arcpy.mapping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MXD = arcpy.mapping.MapDocument(&lt;/SPAN&gt;&lt;SPAN style="font-style: italic;"&gt;Path to .mxd&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;prjFile = &lt;/SPAN&gt;&lt;SPAN style="font-style: italic;"&gt;Path to .prj file&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;-- NOTE: I am not using the InstalDir/Coordinate Systems files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sr = arcpy.spatialReference(prjFile)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for DF in arcpy.mapping.ListDataFrames(MXD):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; DF.spatialReference = sr&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems I can get properties such as the name, type etc. of the data frame coordinate system just fine but I am unable to set thecoordinate system using the above code. I do note that I am NOT using the install coordinate system files. Reason being is I am working on a citrix version of ArcMap, so effectively I don't have access to these files as a normal desktop user would. I was thinking Icould just copy the reference system from a feature class sitting on a computer I do have access to but, again, this doesn't seem to work. Do I need to have access to the installation coordinate systems files in order for this to work? Or is there a way around this? Or is my code totally wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help is much appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Crystal&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 19:18:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532586#M41722</guid>
      <dc:creator>CrystalCarreon</dc:creator>
      <dc:date>2012-10-11T19:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with changing Spatial Reference of data frame using Python</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532587#M41723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Crystal,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you saving your MXD after you apply the change?&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import mapping

prjFile = r"C:\DATA\VECTOR\LOCAL\chester_county.prj"
sr = arcpy.SpatialReference(prjFile)

mxd = mapping.MapDocument(r"C:\temp\python\Airports.mxd")
for df in arcpy.mapping.ListDataFrames(mxd):
&amp;nbsp;&amp;nbsp; df.spatialReference = sr

mxd.save()

del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:09:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532587#M41723</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T23:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with changing Spatial Reference of data frame using Python</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532588#M41724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I feel embarrassed to say this but no, I hadn't saved and that worked. It is working now. THANK YOU!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 19:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532588#M41724</guid>
      <dc:creator>CrystalCarreon</dc:creator>
      <dc:date>2012-10-11T19:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with changing Spatial Reference of data frame using Python</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532589#M41725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also pipe in a WKID code in replace of a prjFile like &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;sr = arcpy.SpatialReference(3857) which is the Web Mercator Projection to bypass that project file step.&amp;nbsp; Also I got hung up on the df.spatialReference = sr .....I capitalized Spatial as some help articles on ESRI reference it that way.&amp;nbsp; Thanks for the clear exacting code! It helped me stop pulling my hair out.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 20:55:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-changing-spatial-reference-of-data/m-p/532589#M41725</guid>
      <dc:creator>DylanKennard</dc:creator>
      <dc:date>2016-06-03T20:55:04Z</dc:date>
    </item>
  </channel>
</rss>

