I am trying to write a python script to do a batch extraction of pixel values. I have a feature class in a file geodatabase that has about 6500 records in it, and I also have a list of rasters. I am trying to write code that will select one point at a time based on an attribute called 'cellnum', scroll through the list of rasters and see if the point overlaps with any of the rasters, and if it does, it will extract the pixel value. However, the points are in WGS84 and my rasters are all in different UTM zones. I need to reproject the selected point to match the raster in question (the script doesn't do on-the-fly projections).However, when I try to reproject the selected point, I get errors.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()))
I get the error message:Failed to execute. Parameters are not valid.ERROR 000944: Output feature class cannot be in the in_memory workspace.Failed to execute (Project).I understand that. So I change 'newlyr' to be "C:/Data/temp_sort.lyr", and I get this error:ERROR 999999: Error executing function.Create output feature class failedFailed to execute (Project).I've tried this also, newlyr = "C:/Data/Project.gdb/temp_sort", but still get an error:Runtime error <type 'exceptions.IOError'>: C:/Data/Project.gdb/temp_sort does not existI'd rather not reproject the entire point file each time if I don't have to. This script will be run in the future with other datasets that could be much larger. I'm at my wit's end. Can anyone shed some light?Thanks a million in advance, this has been giving me headaches for over a week now.