Riverside

Indexes with 2.7

Discussion created by Riverside on Aug 3, 2011
Latest reply on Aug 4, 2011 by Riverside
Have indexes changed with python 2.7.  I have code, that works in 2.6 and 10, but in 2.7 and 10.1, its not working as I would expect.  Now some of the indexes work, they just don't want to behave inside of the fc2fc tool, or for that matter in project.

so, if I have an output = fc[17:] + "_prj"
then do
arcpy.conversion.FC2FC (fc, out_wrksp, output)

so, basically
for fc in arcpy.listfeatureclasses():
output = fc[17:] + "_prj"
arcpy.conversion.FC2FC (fc, out_wrksp, output)
import arcpy
import os
from arcpy import env as ENV

ENV.overwriteOutput = True

ENV.workspace = r"C:\Prop8_DEMO\data"

wrksp = ENV.workspace
sr = arcpy.SpatialReference (102100)

#ENV.scratchWorkspace = r"C:\Prop8_DEMO\data\Prop8WGS\Prop8Data.gdb"
#swrksp = ENV.scratchWorkspace
out_wrksp = r"C:\Prop8_DEMO\data\Prop8WGS\Prop8Data.gdb"

wrksps = arcpy.ListWorkspaces ("*.gdb")

for fGDB in wrksps:
    ENV.workspace = fGDB
    print ENV.workspace
    
    fcs = arcpy.ListFeatureClasses()
    
    for fc in fcs:
        desc = arcpy.Describe (fc)
        descSR = desc.spatialReference
        if descSR.name == "WGS_1984_Web_Mercator_Auxiliary_Sphere":
            output1 = fc[17:] + "_prj"
            print "WGS"
            #print fc1
            arcpy.conversion.FeatureClassToFeatureClass (fc, out_wrksp, output1)
            print fc + "  has been copied"
        elif descSR.name == "NAD_1983_StatePlane_California_VI_FIPS_0406_Feet":
            if fc [0:18] == "countyGIS_ACR_GIS_":
                print "NAD countyGIS"
                output2 = out_wrksp + os.sep + fc[18:] + "_prj"
                arcpy.management.Project (fc, output2, sr)
                print fc[0:18] + " has been projected"
            elif fc [0:10] == "Divisions_":
                print "NAD Division"
                output3 = out_wrksp + os.sep + fc[10:] + "_pt_prj"
                arcpy.management.Project (fc, output3, sr)
                print fc [0:10] + " has been projected"
            else:
                pass
            
        else:
            print desc.spatialReference.name
I have triggering exception errors with background processing, actually right now running in arcmap, by load in py window but its not doing anything, still at 0%.  I wrote a project raster which conceptually is close to this although its a bit simpler, in that i do not have multiple if statements along with describe, but the core code for the parameters of project raster is pretty much the same but with vector.  That script also did not have indexes within the parameters of the tool.


import arcpy
import os
from arcpy import env as ENV

ENV.overwriteOutput = True

ENV.workspace = r"C:\Prop8_DEMO\data"

wrksp = ENV.workspace
sr = arcpy.SpatialReference (102100)

ENV.scratchWorkspace = r"C:\Prop8_DEMO\data\Prop8WGS\Prop8Data.gdb"
swrksp = ENV.scratchWorkspace

wrksps = arcpy.ListWorkspaces ("*.gdb")

for fGDB in wrksps:
    ENV.workspace = fGDB
    print ENV.workspace
    
    rasters = arcpy.ListRasters()
    for rasterdata in rasters:
        print rasterdata
        arcpy.management.ProjectRaster (rasterdata, swrksp + os.sep + rasterdata + "_prj", sr)
        print rasterdata + "  ... has been reprojected"

Outcomes