UPDATE: Cookie Cutter and ArcGIS 10.4

Monday, 21 November, 2016

Way back in 2009 I published a paper on the Cookie Cutter which outlined a method (and accompanying script) for calculating the volume of drumlins. This worked in ArcGIS 9.2 using the Python interface to a number of ArcGIS toolbox tools. Fast forward 9 years since I first wrote the script and, not too surprisingly, it doesn’t work (thanks for telling me Arturs!).

I finally sat down a few weeks ago to bug fix the script which was actually easier than I thought it would. It’s actually comprised of two scripts - the first sets up some working directories and takes an input shapefile, splitting into a number of new shapelines (one per drumlin). The second script then performs the volume calculation on each drumlins. It turns out (given Im pretty much only calling Toolbox tools) that there wasn’t much to fix… a third party script splitting the initial shapefile had to be removed, a bug in the command adding a new field and then reference to ArcGIS 10.4 paths. For those wanting to use it, please download the attached files and follow the notes below.

<

ul>

  • I use WinPython 2.7 and then the excellent Spyder IDE to run the scripts from
  • in Spyder you need to change the Python console to the path of the one that ArcGIS has installed. Goto Tools -> Preferences -> Console -> Advanced Settings then change “Use the following Python Interpreter”. It should be something like:
    C:Python27ArcGIS10.4python.exe
  • at the top of the cookie_setup script set the project_directory to the location of the main input shapefile. For outlines, set the name of the input shapefile
  • Press F5 to run the setup script, creating the working directories and adding a new field to the shapefile
  • the next part needs to be performed manually (I haven’t had time to add in and test the Toolbox call)… add a new text field to the outlines attribute table called “split” and consecutively number each row from A1 to An (ie your last row). In QGIS the expression in the field calculator is
    concat(‘A’, @row_number )
  • save the file then use the ArcGIS Toolbox tool Analysis Tools->Extract->Split
  • use this to split the outlines shapefile based upon the “split” field you just created. Specify the “Target Workspace” as the “input” directory that has been created in your project directory
  • now load Cookie_Cutter into Spyder and again specify the following 5 inputs: project_directory : the project directory nextmap_dsm_img : the input DEM gp.cellSize : the DEM cellsize (in metres) tension_parameter : leave this as it is buffer_parameter : the distance to buffer your drumlins (in metres). The example shows 20m, for a 5m DEM
  • on line 66-68 you might need to change the path to the listed toolboxes. This is specified for 10.4 at the moment
  • RUN IT! The console pane in Spyder should show you a whole load of information as it processes each drumlin. There will be a counter showing you which drumlin you are on
  • The key output is the Volume_Master.dbf table. You can open this in excel. It is zonal stats from ArcGIS for each individual drumlin (subtracted from the cookie cut DEM). The critical value is the SUM column that shows the total height for all pixels within the drumlin. Multiply this by 25 (for a 5x5 pixel) to give you drumlin volume.

    UPDATE: If you can’t (or don’t want to) use Spyder you can just run the py script directly from the command line using the interpreter that ships with ArcGIS.

    Download

    Add comment

    Fill out the form below to add your own comments