<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conditional statement to force two raster elevation surfaces to not intersect in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719560#M104293</link>
    <description>&lt;P&gt;If you have Spatial Analyst, you could do this using &lt;A href="https://doc.esri.com/en/arcgis-pro/latest/tool-reference/spatial-analyst/focal-statistics.html" target="_blank" rel="noopener"&gt;Focal Statistics&lt;/A&gt; and &lt;A href="https://doc.esri.com/en/arcgis-pro/latest/tool-reference/spatial-analyst/set-null.html" target="_blank" rel="noopener"&gt;Set Null&lt;/A&gt;.&amp;nbsp; Just be sure to update the neighborhood size (nbr_size variable) to reflect your actual data.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy.sa import *

# === CONFIGURATION ===
upper_raster_name = "Upper_Surface"   # Name of upper raster layer in Pro
lower_raster_name = "Lower_Surface"   # Name of lower raster layer in Pro
output_lower_name = "Lower_Corrected" # Output corrected lower surface
nbr_size = 50                         # Neighborhood size in cells (must span error gaps)
# =====================

arcpy.env.overwriteOutput = True

upper = Raster(upper_raster_name)
lower = Raster(lower_raster_name)

# Isolate valid positive differences (Upper - Lower &amp;gt; 0)
diff = upper - lower
valid_diff = SetNull(diff &amp;lt;= 0, diff)

# Compute local average gap using surrounding valid data
local_avg_diff = FocalStatistics(valid_diff, NbrRectangle(nbr_size, nbr_size, "CELL"), "MEAN", "DATA")

# Apply conditional adjustment where Lower &amp;gt;= Upper
fixed_lower = Con(lower &amp;gt;= upper, upper - local_avg_diff, lower)

# Save output
fixed_lower.save(output_lower_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Aug 2026 14:37:13 GMT</pubDate>
    <dc:creator>BrennanSmith1</dc:creator>
    <dc:date>2026-08-10T14:37:13Z</dc:date>
    <item>
      <title>Conditional statement to force two raster elevation surfaces to not intersect</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719197#M104271</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Using ArcGIS Pro, I have 2 raster&amp;nbsp;elevation surfaces&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;over a large area&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;I&amp;nbsp;will call&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Upper and Lower&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;which should never intersect.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Upper should always be above&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;the&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;Lower&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;surface.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;The elevation difference varies between the two surfaces.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;But because of errors or inconsistency in the data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;occasionally&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;they&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;intersect&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and for instance over a small area&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;the Lower may&amp;nbsp;rise above the upper. I am looking at creating a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;conditional statement&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;where&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;the&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Lower&amp;gt;Upper it take&lt;/SPAN&gt;&lt;SPAN class=""&gt;s&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;the average&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;elevation&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;distance between the t&lt;/SPAN&gt;&lt;SPAN class=""&gt;wo surfaces&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;in the local area&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;(beyond the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;erroneous intersection&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;between&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;the two surface and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;pushes down the lower surface&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;by that amount so the two surfaces no longer intersect and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;in the area of the erroneous intersection&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;and&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;the Lower is now below the Upper b&lt;/SPAN&gt;&lt;SPAN class=""&gt;y the average elevation difference between them in the local area.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2026 12:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719197#M104271</guid>
      <dc:creator>JohnEsch2</dc:creator>
      <dc:date>2026-08-07T12:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement to force two raster elevation surfaces to not intersect</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719560#M104293</link>
      <description>&lt;P&gt;If you have Spatial Analyst, you could do this using &lt;A href="https://doc.esri.com/en/arcgis-pro/latest/tool-reference/spatial-analyst/focal-statistics.html" target="_blank" rel="noopener"&gt;Focal Statistics&lt;/A&gt; and &lt;A href="https://doc.esri.com/en/arcgis-pro/latest/tool-reference/spatial-analyst/set-null.html" target="_blank" rel="noopener"&gt;Set Null&lt;/A&gt;.&amp;nbsp; Just be sure to update the neighborhood size (nbr_size variable) to reflect your actual data.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy.sa import *

# === CONFIGURATION ===
upper_raster_name = "Upper_Surface"   # Name of upper raster layer in Pro
lower_raster_name = "Lower_Surface"   # Name of lower raster layer in Pro
output_lower_name = "Lower_Corrected" # Output corrected lower surface
nbr_size = 50                         # Neighborhood size in cells (must span error gaps)
# =====================

arcpy.env.overwriteOutput = True

upper = Raster(upper_raster_name)
lower = Raster(lower_raster_name)

# Isolate valid positive differences (Upper - Lower &amp;gt; 0)
diff = upper - lower
valid_diff = SetNull(diff &amp;lt;= 0, diff)

# Compute local average gap using surrounding valid data
local_avg_diff = FocalStatistics(valid_diff, NbrRectangle(nbr_size, nbr_size, "CELL"), "MEAN", "DATA")

# Apply conditional adjustment where Lower &amp;gt;= Upper
fixed_lower = Con(lower &amp;gt;= upper, upper - local_avg_diff, lower)

# Save output
fixed_lower.save(output_lower_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2026 14:37:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719560#M104293</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2026-08-10T14:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement to force two raster elevation surfaces to not intersect</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719622#M104296</link>
      <description>&lt;P&gt;You can model this in ArcGIS Pro with Raster Calculator using a Con (conditional) that only modifies the “bad” cells (where Lower &amp;gt; Upper) and uses Focal Statistics (Mean) to estimate the local typical separation outside/around the error.&lt;/P&gt;&lt;P&gt;Try these steps using the Raster Calculator:&lt;BR /&gt;&lt;STRONG&gt;Compute the separation (gap) raster:&lt;/STRONG&gt;&lt;BR /&gt;gap = upper - lower&lt;BR /&gt;&lt;STRONG&gt;Get a local mean gap (choose a neighborhood large enough to extend beyond the erroneous intersection)&lt;/STRONG&gt;&lt;BR /&gt;gapMean = FocalStatistics(gap, NbrRectangle(15,15,"CELL"), "MEAN")&lt;BR /&gt;&lt;STRONG&gt;Lower only where it violates Upper, using the local mean gap&lt;/STRONG&gt;&lt;BR /&gt;lower_fixed = Con(lower &amp;gt; upper, upper - gapMean, lower)&lt;BR /&gt;&lt;BR /&gt;This sets the corrected lower surface to be below the upper by the local average gap (rather than just clamping to upper).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2026 16:48:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conditional-statement-to-force-two-raster/m-p/1719622#M104296</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2026-08-10T16:48:36Z</dc:date>
    </item>
  </channel>
</rss>

