Select to view content in your preferred language

gp.project not working with shorthand of prj

789
3
Jump to solution
05-14-2012 02:00 PM
ElaineKuo
Regular Contributor
System ArcGIS 9.3

Problem

I tried to project using shorthand of 1984 prj.
However, it failed and said
ERROR 999999: Error executing function.
A locator with this name does not exist.
Failed to execute (Project).

Please kindly explain the error cause and advise any modification in need of the code below.
Thanks a lot.

##Script Name: Project shapefiles (batch) ##Description: project multiple shapefiles ##Created By: Elaine Kuo ##Date: 08/05/2012  #Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)  #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "H:/temp/test1"  #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "H:/temp"  # Set the spatial reference variable cs = "C:/Program Files/ArcGIS/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj"  #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses()  # Loop through every item in the list that was just generated for fc in fcs:      # Break out the name, no path or extension, using the describe object.     desc = gp.describe(fc)     featureName = desc.name      # Make featureclasses as layers     outFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(featureName, outWorkspace)     gp.Toolbox = "management"     gp.Project(fc, outFeatureClass, cs)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Alum
Thanks for the answer.

1. transformation:
    It is not in need to change from Behrmann WGS 1984 to WGS 1984.
    (Please kindly correct me if it is wrong.)


No, sounds fine.

2.  Also thanks for not hardcoding the path.
    However, my version is ArcGIS 9.3
    Please kindly suggest any modification from ArcGIS 10 to 9.3.


Use "gp" instead of "arcpy":

GetInstallInfo" rel="nofollow" target="_blank">http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?T... method (9.3 help)

View solution in original post

0 Kudos
3 Replies
curtvprice
MVP Alum
I do suggest not hardcoding the path. Here's how you do that:

# Set the spatial reference variable
prjHome = arcpy.GetInstallInfo()["InstallDir"]
cs = prjHome + "/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj"


Also, note that you may have to supply a transformation for the Project run to work if the datums are different. The best way to find matches is to run the tool interactively between the two coordinate systems - the popup will give you a choice of transformations to use. Use of transformations is documented in the online help here, with details in a "geographic_transformations"  pdf file in the install folder's Documentation folder.
0 Kudos
ElaineKuo
Regular Contributor
Thanks for the answer.

1. transformation:
    It is not in need to change from Behrmann WGS 1984 to WGS 1984.
    (Please kindly correct me if it is wrong.)

2.  Also thanks for not hardcoding the path.
    However, my version is ArcGIS 9.3
    Please kindly suggest any modification from ArcGIS 10 to 9.3.
0 Kudos
curtvprice
MVP Alum
Thanks for the answer.

1. transformation:
    It is not in need to change from Behrmann WGS 1984 to WGS 1984.
    (Please kindly correct me if it is wrong.)


No, sounds fine.

2.  Also thanks for not hardcoding the path.
    However, my version is ArcGIS 9.3
    Please kindly suggest any modification from ArcGIS 10 to 9.3.


Use "gp" instead of "arcpy":

GetInstallInfo" rel="nofollow" target="_blank">http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?T... method (9.3 help)
0 Kudos