rralbritton

Loop - convert layer to raster coming up blank

Discussion created by rralbritton on Oct 1, 2013
Latest reply on Oct 2, 2013 by rralbritton
I am looping through files, selecting out building footprints one by one and converting the selected building footprint to a raster. The script worked fine for about 2 hours this morning then stopped working. Suddenly all the rasters started coming up blank and I can't figure out why. The script says its running successfully. Thoughts?


import arcpy, os, shutil
from arcpy import env
from arcpy.sa import*

#set workspaces
arcpy.env.workspace = "C:\\ArcGIS\\SurfCityData\\Data" #arcpy.GetParameterAsText(0)
arcpy.env.overwriteOutput = True
outputWorkspace = "C:\\ArcGIS\\SurfCityData\\Data\\Scratch" #arcpy.GetParameterAsText(1)

# Check out the ArcGIS 3D Analyst extension license
arcpy.CheckOutExtension("3D")
arcpy.CheckOutExtension("Spatial")

#Variables
Year = "2005" #arcpy.GetParameterAsText()
Elevation = "C:\\ArcGIS\\SurfCityData\\Data\\LiDAR_DEM_2005\\mosiac_2005" #arcpy.GetParameterAsText(2)
ObsPts = "C:\\ArcGIS\\SurfCityData\\Data\\test_pts2005_prj.shp" #arcpy.GetParameterAsText(3)
footprint =  "C:\\ArcGIS\\SurfCityData\\Data\\Footprints\\BuildingFootprints_SC.shp"
Ocean = "C:\\ArcGIS\\SurfCityData\\Data\\AtlanticOcean.shp" #arcpy.GetParameterAsText()

#Set analysis extent to elevation raster
arcpy.env.extent = Elevation
#Create Featue Layers
PointsFL = outName(ObsPts,"_Layer")
footprintFL = outName(footprint,"_FL")
arcpy.MakeFeatureLayer_management(ObsPts, PointsFL)
arcpy.MakeFeatureLayer_management(footprint,footprintFL)

#Select observation points one by one
RangeCount = int(arcpy.GetCount_management(PointsFL).getOutput(0))
for points in range (0,RangeCount):
    FID = "FID=%s" % (points)

    #Change elevation of building footprint to zero for a selected obs. point
    
    arcpy.SelectLayerByAttribute_management(PointsFL,"NEW_SELECTION",FID)
    print "\n", arcpy.GetMessages()
    arcpy.SelectLayerByLocation_management(footprintFL,"INTERSECT",PointsFL,"","NEW_SELECTION")
    print "\n", arcpy.GetMessages()
    RastFootprint = outputWorkspace+"\\fp_"+str(FID)[4:].split(".")[0]
    arcpy.PolygonToRaster_conversion(footprintFL,"FID",RastFootprint,"MAXIMUM_AREA")
    print "\n", arcpy.GetMessages()

Outcomes