I am working on spatial interpolation. To extract values for my required points, I am using "Extract values to points" tool from Spatial interpolation toolbox. The tool is working good in ArcMap 10.5. But when I try to use the tool from ArcPy. Same value is generated for each point in test set. Here is my code:
<SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;">#point extraction</SPAN><SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Set local variables</SPAN>inPointFeatures = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"test.lyr"</SPAN>inRaster = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"out1"</SPAN>outPointFeatures = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"extractvaluespts.dbf"</SPAN><SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Check out the ArcGIS Spatial Analyst extension license</SPAN>arcpy.CheckOutExtension(<SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"Spatial"</SPAN>) <SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Execute ExtractValuesToPoints</SPAN>ExtractValuesToPoints(inPointFeatures, inRaster, outPointFeatures, <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"INTERPOLATE"</SPAN>, <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"VALUE_ONLY"</SPAN>)
My code for test point layer is as follow:
<SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;">##XY layer for test</SPAN><SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Set the local variables</SPAN>in_Table = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"test.csv"</SPAN>x_coords = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"LONGITUDE"</SPAN>y_coords = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"LATITUDE"</SPAN>z_coords = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">""</SPAN>out_Layer = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">"test"</SPAN>saved_Layer = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">r"C:\Users\myc\Desktop\thesis combine\weather parameters\max temp\with elevation\chk1\test.lyr"</SPAN><SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Set the spatial reference</SPAN>spRef = <SPAN class="" style="color: var(--highlight-variable); border: 0px; font-weight: inherit; font-size: 13px;">r"Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"</SPAN><SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Make the XY event layer...</SPAN>arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer, spRef, z_coords) <SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Print the total rows</SPAN>print(arcpy.GetCount_management(out_Layer)) <SPAN class="" style="color: var(--highlight-comment); border: 0px; font-weight: inherit; font-size: 13px;"># Save to a layer file</SPAN>arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
I am unable to understand the reason behind this error?
P.S. When I work with geostatistical analyst tool set and GA to points, it works perfect, but I require to use raster calculator that's why I cannot use Geostatistical analyst. How can I fix this? Results are attached, no value cahnge in rastervalu.