import arcpy from arcpy import env env.overwriteOutput = True env.workspace = "C:/Data/Project.gdb" env.scratchWorkspace = env.workspace sort = "points" inlyr = "in_memory\\sort" newlyr = "in_memory\\sort2" hypdir = arcpy.ListRasters("") arcpy.MakeFeatureLayer_management(sort, inlyr) rows = arcpy.SearchCursor(inlyr) for row in rows: center = row.getValue("cellnum") Expression = "\"cellnum\" = " + str(center) if center == 0: arcpy.SelectLayerByAttribute_management(inlyr, "NEW_SELECTION", Expression) point = arcpy.SearchCursor(inlyr) for i in point: for scene in hypdir: des = arcpy.Describe(scene) descr = arcpy.Describe(inlyr) sr1 = des.spatialReference sr2 = descr.spatialReference if sr1 != sr2: print "Matching projections..." arcpy.Project_management(inlyr, newlyr, str(sr1.exportToString()))
The Spatial Reference of the feature class
By default, the spatial reference of the geometry returned from a search cursor is the same as the feature class opened by the cursor. You can also set the spatial reference on an update or insert cursor.
import arcpy from arcpy import env from arcpy import management as dm inspace = "C:/test" env.workspace = inspace sort = "pointfile" hypdir = arcpy.ListRasters("","TIF") dm.MakeFeatureLayer(sort,inlyr) for scene in hypdir: des = arcpy.Describe(scene) sr1 = des.spatialReference rows = arcpy.SearchCursor(inlyr, "", sr1) for row in rows: ID = row.getValue("ID") Expression = "\"ID \" = " + str(ID) dm.SelectLayerByAttribute(inlyr, "NEW_SELECTION", Expression