Select to view content in your preferred language

IDW in arcpy not working

749
3
03-17-2022 07:39 AM
Fsbei
by
New Contributor

Hello all,

 

First post after many years of lurking. I am currently building a workflow in python. I am trying to use IDW to create a wind direction map.  The input is a fc containing the location of weatherstations and the recorded wind directions. When I run the IDW tool from arcgis itself it works fine. However, when I try to recreate the map using arcpy I keep getting a raster with a single value. All parameters are the same in both the arcgis desktop and the arcpy script. 

Is there a known issue with IDW when using arcpy? 

 

See extract from script below:

 

input_tbl = r'...windspeed.csv'
workspace = r'...\scratch.gdb'

#environment settings
arcpy.env.workspace = workspace
arcpy.env.overwriteOutput = True

spatial_ref = arcpy.SpatialReference(4326)

out_weatherstations = arcpy.management.XYTableToPoint(input_tbl,'weather_stations','long','lat','',spatial_ref)

print('point created')

out_IDWdirection = arcpy.sa.Idw(out_weatherstations,
"direction_degrees",
2000,
2,
'VARIABLE 12',
None);

out_IDWdirection.save(r'/...IDW_direction')

 

0 Kudos
3 Replies
SteveLynch
Esri Regular Contributor

- how many columns and rows does the output raster have?

- do the input points display within the extent of the raster?

- include a print of the number of records in out_weatherstations, use GetCount, in your script to see how many points are going into IDW

0 Kudos
Fsbei
by
New Contributor

Thanks @SteveLynch . Your comment on the extent made me look more closely to the environment settings within the script. Simply stating the extent didn't work but stating that the env outputs spatial reference must be set to UTM did the trick! Within the arcgis project I had already set my environmental settings but ofcourse this was not set within the script. I think the cause of the empty output is that the IDW was calculated within the WGS84 ref. This of course can cause some conflicts with the given values I provided. 

0 Kudos
RachelGomez
Emerging Contributor

Repair ArcMap using one of the following steps: Rerun the installation tool, and click the Repair radio button. Navigate to the Control Panel > Programs > Programs and Features > Uninstall a program, and double-click ArcGIS for Desktop. Click the Repair radio button.

Regards,

Rachel Gomez

0 Kudos