I am new to Python for ArcGIS, but have been using ArcGIS a while. I have a large directory of tables with point data. For each file of each folder I want to create a kernel density layer. I have managed to write a script that finds all the files (using os.walk) and creates an event layer however the resulting kernel density raster is blank, i.e. all cells have the same value.
When I use the GUI to create the kernel density, using the event layers that I created with the script the kernel density layer comes out beautifully.
I think it is the file formats that I'm having issues?? I tried different types but only .tif creates anything at all. Here is my function to run the kernel density after the file has been found and the event layer created.
def RunKernel(feature): inFeatures = feature populationField = "NONE" cellSize = 1.5E-3 searchRadius = 5000 exten = ".tif" # extention of output file # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute KernelDensity try: outKernelDensity = KernelDensity(inFeatures, populationField, cellSize, searchRadius, "SQUARE_MAP_UNITS") featureName = feature.replace(".lyr", exten) print(featureName) # Save the output outKernelDensity.save(featureName) print (feature, "done") except Exception as err: print(err)