Muskie77

Problem with the Projection/Transformation section of my code

Discussion created by Muskie77 on Jul 8, 2011
Hi,

I'm having an awful time trying to get past this last and latest (I hope) code hurdle in my "ReProject & throw it into a File GDB" effort.

Basically I have an assortment of shapefiles that need to go from the "GCS_North_American_1983" projection to a NAD_1927_California_Teale_Albers" projection. This means I need a 1983_To_1927_NADCON transformation....

Basically this is my error:
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "R:\Temp\arielle\FEMA\CalEMA\python\setprojection.py", line 110, in <module>
    gp.Project_management(shppath, outFeatureClass, cs, "NAD_1983_To_NAD_1927_NADCON")
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000365: Invalid geographic transformation.
Failed to execute (Project).



Which is a response to this section of Code:

                
elif gp.Describe(shppath).SpatialReference.Name == "GCS_North_American_1983":
                        ## projection file
                        cs = 'PROJCS["NAD_1927_California_Teale_Albers",GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",-4000000.0],PARAMETER["Central_Meridian",-120.0],PARAMETER["Standard_Parallel_1",34.0],PARAMETER["Standard_Parallel_2",40.5],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'
                        ## need to remove numbers, if they are first in the filename
                        if filename[0] in numlist:
                                filename = 'a_' + filename
                        ## need to remove whitespace
                        ## filename = filename.replace(' ', '')
                        filenameclean = gp.ValidateTableName(filename)
                        outFeatureClass = "Test.gdb/" + filenameclean[:-4]
                        if gp.exists(outFeatureClass):
                                outFeatureClass = "Test.gdb/" + filenameclean[:-4] + str(counter)
                        gp.Project_management(shppath, outFeatureClass, cs, "NAD_1983_To_NAD_1927_NADCON")
                        print "Wrong Projection, Transformed: " + shppath


...I'll include the whole code if you contact me directly....but I don't think this is a logic error....I think it has something to do with how you use transformations in the gp.Project_management method.

Outcomes