mbbrady

For Loop: Convert Point to Raster and Keep Base File Name In Output

Discussion created by mbbrady on May 3, 2012
Latest reply on May 10, 2012 by mbbrady
Hi,

I'm very new to Python. I'm attempting to convert multiple point shapefiles to GRIDs and retain the base file name of each input shapefile. When I run my script, Python crashes with no helpful error message. I've also noticed that when I try to run the script a second time after I've made edits, the data become inaccessible and I have to close all programs, and delete the folder containing my shapefiles before Python will work (up to where it crashes). I've been working on this for days and have made no progress. I'd really appreciate any pointers.

Note: I've successfully run the script when I convert one file and specify a string name. I believe the problem I'm having has to do with how I'm naming the output.

My script:

# Set local environment:
Path = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\"
Working = Path + "nexrad_Irene_Working" 
arcpy.env.workspace = Working
arcpy.env.overwriteOutput = 1
# Set local variables:
NEXRAD2grid = arcpy.ListFeatureClasses()
HRAP_Projection = "PROJCS['HRAP_Projection',GEOGCS['HRAP_GCS',DATUM['D_HRAP',SPHEROID['HRAP_Sphere',6371200.0,0.0]],PRIMEM['<custom>',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Standard_Parallel_1',60.0],UNIT['HRAP_Grid',4762.5]]"

arcpy.env.outputCoordinateSystem = HRAP_Projection
arcpy.env.extent = "-236 -1476 661 -806"
arcpy.env.cellSize = "1"


for fc in NEXRAD2grid:
    desc = arcpy.Describe(fc)
    filename = desc.name
    NEXRADgrids = filename[:-4]
    arcpy.PointToRaster_conversion(fc, "Globvalue", NEXRADgrids, "MAXIMUM", "NONE", "1") #execute point to raster
    print NEXRADgrids

Outcomes