Select to view content in your preferred language

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

5367
13
Jump to solution
02-20-2015 08:34 AM
TorstenLange
Occasional Contributor

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
1 Solution

Accepted Solutions
TorstenLange
Occasional Contributor

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.

View solution in original post

0 Kudos
13 Replies
DanPatterson_Retired
MVP Emeritus

modelbuilder used "10" and "1" in double quotes

your script used numbers 10 and 1

they are not the same

0 Kudos
TorstenLange
Occasional Contributor

Actually, as I wrote, I tried both, the version from the model builder and the version proposed in the ArcGIS-help. Both versions run without any error, but no smoothing. I can, however, easily adjust cell size or the field of the Z values in both versions. I'm aware of the inconsistency refereing to the different application of the cell size and smoothing parameters (string vs "numbers"). But these two versions are coming from ArcGIS itself.

I have the problem, that running the exported model builder code inside the ArcGIS python client works perfect. If I run exactly the same code from the console smoothing doesn't happen. In the ArcGIS help, the smoothing factor is not applied in the examples.

I'm also confused about the small difference in the function parameters:

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

ArcGIS help: outSplineBarriers = SplineWithBarriers(points_shp, "id", faults_shp, 10,{1})

Seems, there happens some wrapping around some other code (e.g. the Java code that is used behind).

So actually, it would be helpful to have a code snippet that is supposed to work including smoothing from an external script. Just to see if there are problems with the environment or with different python versions etc. There was a suggestion from a colleage that ArcGIS uses two Python versions (32 and 64 bit).

Hmm...?

0 Kudos
DanPatterson_Retired
MVP Emeritus

{ } simply means an optional parameter... on a lark...try a factor of 0.9 instead of 1 since there is some suggestion that the smoothing factor shouldn't be randomly chosen see this link near the bottom

0 Kudos
TorstenLange
Occasional Contributor

Thanks, Dan, I try your suggestion as soon as I'm at the desk again. I'm very on the edge , as I lost almost a day. Unfortunately (...or good) I don't have ArcGIS at home.

Indeed, we actually running the splinewithbarrier() for two cell sizes, 50 m and 10 m and combine those in a later step with having 10 m density close to our faults or barriers, and 50 m elsewhere. So, the 50 m grid is smooth, but the 10 m grid has an ugly stepping, which is about 1 m between the steps. The original isoline distance is 10 m. I mean, for our purpose it's not completely bad, but it makes people uncertain. And that has to be improved. But, when thinking about, and scale effects are in play, than I wonder why from within the arcgis python client smoothing seems to be better. This would mean that internally some scale depend corrections to the smoothing factor are applied without notice in the help.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Ahhhh now I do see what might be the problem...if your cell size is approaching the contour spacing there is no intervening space (aka cells) to calculate values for which may be leading to the stepped appearance there.  You can only experiment with a small sample in the area where this is happening, then changing the cell size with the (perhaps varying) smoothing parameter.  Posting some screen shots might twig someone's memory

0 Kudos
TorstenLange
Occasional Contributor

Sorry, I wrote mistakable - its not like that. The isolines are every 10 m - like 250, 260, 270 etc. 'Guess, contour level was the appropriate term. Distances between 10 m isolines of less than 10 m don't exist. It's about a rather gentle morphology of geological layers - no steep gradients. I could provide some screen shots on monday...

0 Kudos
DanPatterson_Retired
MVP Emeritus

oh good...that is much better...screen shots on Monday then

0 Kudos
TorstenLange
Occasional Contributor

Ok, that's how it looks. I got two screen shots, actually from our 3D geometrical modeling software to have a better view on the data. The grid cells are represented by the points now. What one can clearly see ist the difference between running from inside ArcGIS (graphical dialog or python client) and the from external script.resulting_grid_inside_arcgis.png

Screen shot 1: inside Arcgis

resulting_grid_with_external_script.png

Screen shot 2: Result from external script

0 Kudos
DanPatterson_Retired
MVP Emeritus

To me, it looks like the contours are where the gaps are in the latter figure.  Is that the case?  I would determine whether or not a smoothing factor <1 removes them and/or whether using a size other than 10 removes them given that 50 seems to be ok.  I can see no other reason if both are being viewed within the same software.  If the results are being viewed in different software then it may be due to the display environment

0 Kudos