AnsweredAssumed Answered

IDW interpolatation using ArcPy

Question asked by Pedro_Gonzaga94 on Aug 3, 2020
Latest reply on Aug 3, 2020 by danretired

I have multiple point feature class (las_1.shp, las_2.shp....._711) into one folder. I am trying to write a python script to perform IDW interpolation which will loop all the point feature class and outraster will save as it name of input raster. 

Each Point feature class hold  one Z filed only (Altit).

The problem is that after interpolation some of the generated raster are saved, however, with an error (all black). I think that the problem is in the part of save the raster (os.path.join) because a execute the script without this part and the interpolation works perfectly. I'm using Python 2.7.

 

Below is my script, what i have so far

import arcpy
from arcpy import env
from arcpy.sa import *
import os
arcpy.env.parallelProcessingFactor = "100%"
arcpy.env.overwriteOutput = True

# settings
env.workspace = r"C:\Users\pedro\Documents\Mestrado\GEO\Pontos_Laser\TESTE"
out_folder = r"C:\Users\pedro\Documents\Mestrado\GEO\Pontos_Laser\RASTER"
zField = "Altit" # has to be string, not list

points = arcpy.ListFeatureClasses("las_*.shp", "POINT")
print points

cellSize = 5
power = 2
searchRadius = RadiusVariable(12, 5)

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

# Execute IDW
for fc in points:
    print fc
    outIDW = Idw(fc, zField, cellSize, power, searchRadius)
    #Save output raster to output workspace
    tifname = fc[:7]
   
    # Save output
    IDW_OUT= os.path.join(out_folder, '{}.tif'.format(tifname))
    print IDW_OUT
    outIDW.save(IDW_OUT)

print 'done'

Outcomes