perform IDW interpolation to select multiple Z field from attribute table using ArcPy

7419
37
Jump to solution
08-21-2016 10:29 AM
ShouvikJha
Occasional Contributor III

I have 12 point feature datasets for different month. I want to perform IDW interpolation.

I have created the python code but its taking only one "Z" field for different month feature datasets from the attribute. Below I have mentioned the code. How to assign here multiple Z field from each month folder (JANUARY, FEBRUARY......DECEMBER).

Point feature class from different month folder (e.g. For January Merged_001, for FEBRUARY Merged_002.......for DECEMBER Merged_012 ) and want to perform IDW interpolation and save it as on same month folder as it Z field name (Max_Temper, Min_Temper, Precipitatat, Wind, Relative_H, Solar) with month (e.g for January 001_Max_Temper, 001_Min_Temper, 001_Precipitatat, 001_Wind, 001_Relative_H, 001_Solar).

After Whatever Solar raster for different month (for January 001_Solar....for DECEMBER 012_Solar) we will get, I want to do some calculation (001_Solar * 30) *0.5 and save it 001_sr ........012_sr in Month wise folder.

Below i have attached Point shapefile also for reference purpose 

Here is my code.

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.parallelProcessingFactor = "100%"
arcpy.env.overwriteOutput = True
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
env.workspace = "D:\SWAT-WEATHER-DATA2\APRIL"
# Set local variables
inPointFeatures = "D:\SWAT-WEATHER-DATA2\APRIL\Merged_004.shp"
zField = "Min_Temper" #Z_Filed = Max_Temper, Min_Temper, Precipitatat, Wind, Relative_H, Solar
cellSize = 0.002298707671
power = 2
searchRadius = RadiusVariable(10, 150000)
#Mask region of interest
mask="D:\Gujarta Shape file\GUJARATSTATE.shp"

# Execute IDW
outIDW = Idw(inPointFeatures, zField, cellSize, power, searchRadius)
# Execute Mask
IDWMASk = ExtractByMask(outIDW, mask)
# Save output, except Solar Radiation raster
IDWMASk.save("004_Min_Temp.tif")
# 004_Max_Temp.tif, 004_Min_Temp.tif....Solar
#Only for Solar Radiation raster
#PAR = (IDWMASk * 30) * 0.5
#Save output, Only for Solar Radiation raster
#PAR.save("003_sr.tif")
#print done
print 'done'‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
37 Replies
DanPatterson_Retired
MVP Emeritus

 leaving philosophy out of it... can one assume the original points represent the truth? and what errors does using that data introduce in itself.

NeilAyres
MVP Alum

What is the "truth".

Interpolation is interpolation. "Estimating", "predicting", values which are not actually there in your original data but putting some mathematical function through the input points to create a continuous surface raster output. Lots of stuff in the middle. IDW, NN, Splines, even Kriging

NeilAyres
MVP Alum

By the way, thanks xander_bakker for giving us some nice pictures of the various "interpolations"

0 Kudos
XanderBakker
Esri Esteemed Contributor

You're welcome, but I'm sure there are many options to explore that will yield different results and there are many interpolations methods that will yield "better" results. 

Also, very true your remark about estimating and predicting. If possible it is preferable to get back to the source (meteorological stations?). Hard to tell what kind of processes have been applied and on what data to obtain the results. 

DanPatterson_Retired
MVP Emeritus

I will second that... especially it is climatalogical data

ShouvikJha
Occasional Contributor III

Xander BakkerDan Patterson‌. Several researcher has been tested the issue of How effectively different interpolation techniques can predict the missing value  based on known value, they found Kriging is working effectively to predict the missing value. And its very close to the observation. Thank you. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

lets rule out potential sources of error first

  1. file paths need raw format ie  r":\c:\mypath" ... note the r
  2. spaces are almost certain failure
  3. dashes and other undesireables in the paths... like - dashes
  4. indentation.... copy the code open up syntax highlighting, select python... then paste try using 4 spaces per indent level (we have blog posts on this issue... read them)
  5. the input variables to kriging were derived appropriately and reflect the characteristics of the inputs?  I can't test...
  6. put in print statements to insure the input and output names are correct
  7. check parallel processing factor, 100% as a string? or 100 as a number... don't have time to check
  8. line 31 hmm off hand, doesn't like the mask (I think)
ShouvikJha
Occasional Contributor III

Dan Patterson‌. Thank you for the suggestions.. Regarding indentation issues with my posted code i don't know why indentation  occurring even i posted  code very carefully with syntax highlighting. 

0 Kudos
ShouvikJha
Occasional Contributor III

Dan Patterson‌. I exactly followed the same which one you posted. after all this process also indentation issue coming.

  Below i have a attached snapshot 

0 Kudos