arcpy, spatial reference

3329
2
12-09-2011 07:14 AM
SamanthaEdwards
New Contributor II
When setting an ouputcoordinate system in python I keep getting an error.

Here's a sample of the code up to the point where the error occurs.

import arcpy, os, sys
print "Processing ..."

#set up a relative path.  This returns the folder where the script is
relativePath = os.path.dirname(sys.argv[0])

#Set up environment settings
arcpy.env.workspace = "c:/.gdb"
arcpy.env.overwriteOutput = True
arcpy.env.outputCoordinateSystem="Coordinate Systems/Projected Coordinate Systems/State Plane/NAD 1983(US Feet)/NAD 1983 StatePlane Pennsylvania North FIPS 3701(US Feet).prj"

This error is returned:
Traceback (most recent call last):
  File "Y:\Planning\GIS Planning Analyst\projects\county_map_book\1_GenerateIndexLayers.py", line 11, in <module>
    arcpy.env.outputCoordinateSystem="Coordinate Systems/Projected Coordinate Systems/State Plane/NAD 1983(US Feet)/NAD 1983 StatePlane Pennsylvania North FIPS 3701(US Feet).prj"
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 505, in set_
    self[env] = val
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 557, in __setitem__
    ret_ = setattr(self._gp, item, value)
RuntimeError: <unprintable RuntimeError object>


Any help will be greatly appreciated.

SE
Tags (2)
0 Kudos
2 Replies
StacyRendall1
Occasional Contributor III
Runtime error is what it returns if you have given it an incorrect/invalid path. In this case you have missed a space before the (US Feet) both times...

arcpy.env.outputCoordinateSystem="Coordinate Systems/Projected Coordinate Systems/State Plane/NAD 1983(US Feet)/NAD 1983 StatePlane Pennsylvania North FIPS 3701(US Feet).prj"


Should instead be:
arcpy.env.outputCoordinateSystem="Coordinate Systems/Projected Coordinate Systems/State Plane/NAD 1983 (US Feet)/NAD 1983 StatePlane Pennsylvania North FIPS 3701 (US Feet).prj"
0 Kudos
SamanthaEdwards
New Contributor II
Wow, that was easy. Thanks!!
0 Kudos