crystalcarreon

Problem with changing Spatial Reference of data frame using Python

Discussion created by crystalcarreon on Oct 11, 2012
Latest reply on Jun 3, 2016 by Kenndk

Hi-
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:

 

import arcpy.mapping
MXD = arcpy.mapping.MapDocument(Path to .mxd)
prjFile = Path to .prj file <-- NOTE: I am not using the InstalDir/Coordinate Systems files.
sr = arcpy.spatialReference(prjFile)

 

for DF in arcpy.mapping.ListDataFrames(MXD):
   DF.spatialReference = sr

 

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?

 

Any help is much appreciated!
Crystal

Outcomes