1

This seems like to should be an easy thing to do, but I can't seem to make it work.

arcpy.env.workspace = arcpy.GetParameterAsText(0) 
output_working = arcpy.GetParameterAsText(1) 
PLSS_Intersected = arcpy.GetParameterAsText(2) 
spatial_ref = arcpy.GetParameterAsText(3) 
outCS = arcpy.SpatialReference("spatial_ref") 
outfc = os.path.join(output_working, "PLSS_Intersected") 
arcpy.Project_management(PLSS_Intersected, outfc, outCS) 

EDIT:

How is the error massage that I receive. The very top is what prints out when I printed outCS.enter image description here

asked Dec 13, 2016 at 23:08
10
  • "spatial_ref" is a string, but spatial_ref is a variable holding a string. Commented Dec 13, 2016 at 23:14
  • One issue is you are providing the string 'spatial_ref' to arcpy.SpatialReference rather than the value you have assigned to spatial_ref via arcpy.GetParameterAsText(3) Commented Dec 13, 2016 at 23:14
  • How do I correct this? Rather, how do I call the value instead of calling the variable holding the value? Commented Dec 13, 2016 at 23:16
  • outCS = arcpy.SpatialReference(spatial_ref). This uses the variable, not a string that happens to be the variable name. Commented Dec 13, 2016 at 23:19
  • I think it will be worth using print outCS after you get that 4th parameter as text so that you (and we) can see what a test value is that you enter. Commented Dec 13, 2016 at 23:25

1 Answer 1

6

Although the comments have identified the immediate problem (that you are using the string literal, "spatial_ref", rather than the variable, spatial_ref), you may find it easier to change the input parameter to data type = Spatial Reference, and use the spatial reference object itself, rather than converting the spatial reference to string and back to a spatial reference object.

arcpy.env.workspace = arcpy.GetParameterAsText(0) 
output_working = arcpy.GetParameterAsText(1) 
PLSS_Intersected = arcpy.GetParameterAsText(2) 
spatial_ref = arcpy.GetParameter(3) # get spatial reference object
outfc = os.path.join(output_working, "PLSS_Intersected") 
arcpy.Project_management(PLSS_Intersected, outfc, spatial_ref) # set spatial reference to the object
answered Dec 13, 2016 at 23:38
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.