SplineWithBarrier (Spacial Analyst): Different results between Modelbuilder and external PythonScript

4885
13
Jump to solution
02-20-2015 08:34 AM
TorstenLange
New Contributor III

Hi,

I'm puzzled by different results I get from application of SplineWithBarrier (Spacial Analyst) using Modelbuilder and by external Python scripting:

import arcpy

points_shp = "pointShape.shp"

faults_shp = "faultsShape.shp"

outGrid = "r_out"

arcpy.gp.SplineWithBarriers_sa(points_shp, "id", faults_shp, "10", outGrid, "1")

This is the code I got from the model builder. While results there are as expected (smooth surface with discontinuities) I used it in an external script. The resulting surface derived from the external script, however, shows, that smoothing was skipped. Before I tried the version from model builder I followed the example from the ArcGIS help. Same result - the grid is created, but again smoothing step is skipped. My first code was:

import arcpy

points_shp = "pointShape.shp"

faults_shp = "faultsShape.shp"

outGrid = "r_out"

arcpy.CheckOutExtension("Spatial")

outSplineBarriers = SplineWithBarriers(points_shp, "id", faults_shp, 10, 1)

outSplineBarriers.save(outGrid)

That's the syntax from the help:

SplineWithBarriers (Input_point_features, Z_value_field, {Input_barrier_features}, {Output_cell_size}, {Smoothing_Factor})

Why is smoothing not activated? Where is my fault?

Thanks for any hint!

Torsten

0 Kudos
13 Replies
TorstenLange
New Contributor III

I have some more screen shots now. I tried to use smoothing factors between 0 and 1, which doesn't work at all. Neither I can code the smoothing factor by floating point nor by string (0.9, "0.9"). The function actually takes for cell size and smoothing factor either values as strings or as number. But any smoothing factor between 0 and 1 crashes the process when it comes to smoothing, not matter if I give the value as floating point number or string:

Fuer Zellgroesse 50 m...  ( == this run is for 50 grid)

java version "1.6.0_43"

Java(TM) SE Runtime Environment (build 1.6.0_43-b01)

Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

ERROR: 'Spline mit Barrieren' fehlgeschlagen    ( == failed)

ERROR:

Traceback (most recent call last):

  File "contourgridder.py", line 189, in <module>

    outSplineBarriers = SplineWithBarriers(tmp_points, o.Z_field, tmp_stoerungen, cell_size, o.r_glaettung)

File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\sa\Functions.py", line 7079, in SplineWithBarriers

    Smoothing_Factor)

  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\sa\Utils.py", line 47, in swapper

    result = wrapper(*args, **kwargs)

  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\sa\Functions.py", line 7072, in Wrapper

    Smoothing_Factor)

  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>

    return lambda *args: val(*gp_fixargs(args, True))

arcgisscripting.ExecuteError: 'Spline mit Barrieren' fehlgeschlagen

Fehler beim Ausführen von (SplineWithBarriers).  ( == Error during execution of SplineWithBarriers)

Below are the new screen shots. See the huge difference between external script and sript in the ArcGIS python client. Actually, it looks to me now, that the smoothing factor indeed works, but maybe only as True or False (1 or 0) and that there is a difference in how smoothing is applied...?

50_m_grid_blue_smoothed_yellow_not_smoothed.png

Screen shot 1: 50 m grid with smoothing factors 1 (blue) and 0 (yellow), isolines in red.

10_m_grid_blue_smoothed_yellow_not_smoothed.png

Screen shot 2: 10 m grid with smoothing factors 1 (blue) and 0 (yellow), isolines in red.

10_m_result_from_ArcGIS.png

Screen shot 3: 10 m grid from within ArcGIS smoothing factor 1 (blue), isolines in red.

0 Kudos
DanPatterson_Retired
MVP Emeritus

At this stage, I am not sure what you want to do.  My suggestion is use the 50m it looks great to me and I think trying to interpolate at 10 m is a bit overkill and introducing artifacts potentially due to floating point representation of the data.  If moving up from 10, to 20, 30, 40 and your 50, does make the artifacts go away, you will have determined the threshold.  Keep me posted on that process.  Good luck

0 Kudos
TorstenLange
New Contributor III

Thanks for your thoughts, Dan! Luck was on my side It turned out to be as tricky as simple. A member of staff of our local ArcGIS support asked me to perform some testings with very simple paths, as some raster functions seem to be sensitive here. He also suggested to change our system decimal delimiter, even though I was using strictly "." in my python scripts (German delimiter is ",").

The last suggestion made the difference. I can now apply the range between 0 and 1 to the smoothing factor - no matter - as string or floating point.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Grief.....

0 Kudos