1

I am trying to run an IDW on some precipitation points, but when I try to clip the IDW raster to a polygon boundary, it keeps restarting the IDLE shell. This happens when I run it in the shell, and as a complete script. Here is the code:

import arcpy from arcpy import env env.workspace = "C:\\someWorkspace" env.overwriteOutput = True arcpy.CheckOutExtension("3d") #Declare local variable, the points to be interpolated points = "PrecipKansas2014" #Making the points to be interpolated a feature layer, for processing in IDLE arcpy.MakeFeatureLayer_management(points, "points_lyr") #IDW arcpy.Idw_3d("points_lyr", "RASTERVALU", "precipNew") #Clip IDW raster to the polygon state boundary arcpy.Clip_management("precipNew", "KansasBoundary", "idwClip") 

This is as far as I get, as the whole program restarts. The next step would be to arcpy.ExtractByMask() to get data from a specified region, but that will come later.

Using ArcGIS version 10.7.1, no patches applied.

4
  • 1
    Is your 'c:\\someWorkspace' actually an Esri GRID workspace and not just a folder? I assume you've changed the path but that could be a potential cause, there are some very stringent rules to ArcINFO workspaces which you may be contravening inadvertently. Try changing "idwClip" to "idwClip.tif" and see if that helps. In my opinion the shell window of IDLE has its own set of issues, you could try copy/pasting your code into an ArcCatalog python window and see if that helps. I use PyWin32 IDE shell which I've found isn't as buggy as IDLE. Commented Oct 22, 2019 at 3:37
  • 1
    Are you saying that you are running your script from IDLE's Python Script window, and that stays open while IDLE's Python Shell window also stays open but restarts the script without you intervening? Commented Oct 22, 2019 at 4:20
  • @Michael Stimson Thanks, that probably makes the most sense. I tried your suggestion with the "idwClip.tif", and it does the same thing. I might have to try the PythonWin option. Commented Oct 22, 2019 at 15:07
  • @PolyGeo when I save the script and press "F5" to run it, the Python shell opens, and after about a minute, I get the "RESTART: Shell" option. Meaning that it has terminated/crashed and restarted. I hope that answers your question. Commented Oct 22, 2019 at 15:08

1 Answer 1

1

I found that it worked much better to use the ExtractByMask option instead of the arcpy.Clip_management process. The corrected code is as follows:

import arcpy from arcpy import env #Must use the arcpy.sa for this option# from arcpy.sa import * env.workspace = "C:\\workspace" env.overwriteOutput = True points = "PrecipKansas2014" #Check out extensions: arcpy.CheckOutExtension("Spatial") and arcpy.CheckOutExtension("3d") arcpy.MakeFeatureLayer_management(points, "points_lyr") arcpy.Idw_3d("points_lyr", "RASTERVALU", "precipNew") ExtractBymask("precipNew", "KansasBoundary) #Check in extensions: arcpy.CheckInExtension("3d") and arcpy.CheckInExtension("Spatial") 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.