Select to view content in your preferred language

error script with project_management tool

732
6
11-25-2013 06:14 AM
francescodi_vito
Deactivated User
hello guys,
I'm using the script for project features that is in the help of arcgis desktop, but I get a generic error 999999
this is the script code
[HTML]
import arcpy, os
from arcpy import env

# Enviroment Setting
env.workspace = "C:/Users/fdivito/Documents/Commesse/LOMBARDIA_INFORMATICA/PolidroDati/DATI_ANALISI/Feature.gdb"
env.overwriteOutput = True

# Imposta variabile locale su cui viene salvato il risultato dell'operazione
outWorkspace = "C:/Users/fdivito/Documents/Commesse/LOMBARDIA_INFORMATICA/PolidroDati/DATI_ANALISI/Feature_utm.gdb"

try:
    # Use ListFeatureClasses to generate a list of inputs
    for infc in arcpy.ListFeatureClasses():
   
        # Determine if the input has a defined coordinate system, can't project it if it does not
        dsc = arcpy.Describe(infc)
   
        if dsc.spatialReference.Name == "Unknown":
            print ('skipped this fc due to undefined coordinate system: ' + infc)
        else:
            # Determine the new output feature class path and name
            outfc = os.path.join(outWorkspace, infc)
           
            # Set output coordinate system
            outCS = arcpy.SpatialReference('WGS_1984_UTM_Zone_32N')
           
            # run project tool
            arcpy.Project_management(infc, outfc, outCS)
           
            # check messages
            print(arcpy.GetMessages())
           
except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))
   
except Exception as ex:
    print(ex.args[0])
[/HTML]

Any  help please?
Bye
Thanks
Tags (2)
0 Kudos
6 Replies
MichaelVolz
Esteemed Contributor
Can you try adding some print statements into your code to make sure the variables are being properly populated?  Then please include output in a reply.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Francesco,

Remove the underscores in the spatial reference name.  Try the following:

outCS = arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
0 Kudos
MichaelVolz
Esteemed Contributor
Jake:

In a script I have had for awhile I would have the following projection information to convert to UTM PA South

outCS = arcpy.SpatialReference("PROJCS['WGS_1984_Web_Mercator',GEOGCS['GCS_WGS_1984_Major_Auxiliary_Sphere',DATUM['D_WGS_1984_Major_Auxiliary_Sphere',SPHEROID['WGS_1984_Major_Auxiliary_Sphere',6378137.0,0.0]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],UNIT['Meter',1.0]]", "NAD_1983_To_WGS_1984_1;WGS_1984_Major_Auxiliary_Sphere_To_WGS_1984", "PROJCS['NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',1968500.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-77.75],PARAMETER['Standard_Parallel_1',39.93333333333333],PARAMETER['Standard_Parallel_2',40.96666666666667],PARAMETER['Latitude_Of_Origin',39.33333333333334],UNIT['Foot_US',0.3048006096012192]]")

Is there simpler nomenclature in the below form that could have been instead to do this reprojection?

outCS = arcpy.SpatialReference('WGS 1984 UTM Zone 32N')

If so, what would my SpatialReference nomenclature be for UTM PA South?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Michael,

You could perform the following:

outCS = arcpy.SpatialReference("NAD 1983 StatePlane Pennsylvania South FIPS 3702 (US Feet)")
arcpy.env.geographicTransformations = "NAD_1983_To_WGS_1984_1"

arcpy.Project_management(fc, fc + "_project", outCS)
0 Kudos
MichaelVolz
Esteemed Contributor
Jake:

My reprojection additionally needed a transformation, unlike the original poster, which is accounted for with my original much longer nomenclature?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Yes, the transformation is handled by the env variable arcpy.env.geographicTransformations.  This is a semicolon delimited string, so you can specify multiple transformations if needed.  Ex:

arcpy.env.geographicTransformations = "Arc_1950_To_WGS_1984_5; PSAD_1956_To_WGS_1984_6"
0 Kudos