<?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: Minus Tool in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444371#M25358</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you looking to subtract one raster from 724 other rasters?&amp;nbsp; You can accomplish this using a python script.&amp;nbsp; Below is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\Rasters"

arcpy.CheckOutExtension("spatial")

lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus = arcpy.sa.Minus(raster, r"C:\data\raster\TIFF\example1.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus.save(r"C:\temp\python\Rasters" + "\\" + raster + "_minus.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Successfully subtracted raster"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What the above script is doing is selecting all rasters within the 'env.workspace' directory.&amp;nbsp; Then it is subtracting the 'C:\data\raster\TIFF\example1.tif' raster from each one, and finally saving the new raster to the 'C:\temp\python\Rasters' directory with '_minus.tif' appended to the original name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:52:19 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-11T19:52:19Z</dc:date>
    <item>
      <title>Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444370#M25357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm creating a workflow and need to perform an iteration of the Minus Tool. Unfortunately, only one iterator is allowed in a model and I can't tell the tool to get a file from one folder and subtract it from another file from a different folder (724 times). Someone suggested the batch function of the tool, but that requires me to click each file to add it to the list to process. Any work arounds or suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Nov 2011 18:16:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444370#M25357</guid>
      <dc:creator>ChristopherStrother</dc:creator>
      <dc:date>2011-11-15T18:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444371#M25358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you looking to subtract one raster from 724 other rasters?&amp;nbsp; You can accomplish this using a python script.&amp;nbsp; Below is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\Rasters"

arcpy.CheckOutExtension("spatial")

lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus = arcpy.sa.Minus(raster, r"C:\data\raster\TIFF\example1.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus.save(r"C:\temp\python\Rasters" + "\\" + raster + "_minus.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Successfully subtracted raster"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What the above script is doing is selecting all rasters within the 'env.workspace' directory.&amp;nbsp; Then it is subtracting the 'C:\data\raster\TIFF\example1.tif' raster from each one, and finally saving the new raster to the 'C:\temp\python\Rasters' directory with '_minus.tif' appended to the original name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:52:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444371#M25358</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T19:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444372#M25359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help. I wasn't very clear, I'm trying to subtract 724 &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;STRONG&gt;pairs&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; of rasters. I'm creating normalized Digital Surface Models (nDSMs) from 724 DSMs and 724 DEMs. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 22:23:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444372#M25359</guid>
      <dc:creator>ChristopherStrother</dc:creator>
      <dc:date>2011-11-16T22:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444373#M25360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do you determine which raster needs to be subtracted from which?&amp;nbsp; Do the rasters have identical names in each directory?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 10:13:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444373#M25360</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-11-17T10:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444374#M25361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, for example, one is called 123.tif and the other is 123.img.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 10:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444374#M25361</guid>
      <dc:creator>ChristopherStrother</dc:creator>
      <dc:date>2011-11-17T10:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444375#M25362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you have the same amount of rasters in each directory you can do this with the below example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
arcpy.CheckOutExtension("Spatial")

env.workspace = r"C:\temp\python\Rasters"

list1 = []

lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(env.workspace + os.sep + raster)

env.workspace = r"C:\temp\python\Rasters2"

list2 = []

lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list2.append(env.workspace + os.sep + raster)

count = len(list1)

x = 0
while x &amp;lt; count:
&amp;nbsp;&amp;nbsp;&amp;nbsp; raster = list1&lt;X&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name = raster.split("\\")[-1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus = arcpy.sa.Minus(list1&lt;X&gt;, list2&lt;X&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outMinus.save(r"C:\temp\python\Output" + os.sep + name.split(".")[0] + "_minus.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Successfully created raster'
&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1

del list1, list2, raster&lt;/X&gt;&lt;/X&gt;&lt;/X&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script will append each raster to a list, and then subtract each raster from another (ie 123.tif - 123.img).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:52:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444375#M25362</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T19:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444376#M25363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all of your time helping me with this. This will enable me to get over a "hump" that I've been stuck on for two weeks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 17:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444376#M25363</guid>
      <dc:creator>ChristopherStrother</dc:creator>
      <dc:date>2011-11-17T17:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444377#M25364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is kind of similar approach that I am looking for. I have many pairs (2000+) of orthophotos from years 2011 and 2014. They are stored in 2 separate folders. I would also like to find differences between them, but first of all I need to reclassify only one band from orthophoto; orthophotos are composited of red, green and blue band. I need to reclassify only blue band in 2 classes, then subtract them and export result as polygon.&lt;/P&gt;&lt;P&gt;Orthophotos that overlapping each other have same name, except the 8th character is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am attaching picture of model builder process for one set of orthophoto. Orthophotos with name E063462.tif and E063462&lt;STRONG&gt;A&lt;/STRONG&gt;.tif are overlapping each other.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I need to import/load only &lt;STRONG&gt;blue band&lt;/STRONG&gt; from orthophotos that have first 7 characters the same.&lt;/LI&gt;&lt;LI&gt;Then blue bands should be reclassified into 2 classes (threshold values is 130).&lt;/LI&gt;&lt;LI&gt;The reclassified raster should be subtracted (newer minus older).&lt;/LI&gt;&lt;LI&gt;The result should be exported as polygons.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not familiar with python so I need help to write a code to automate this process with 2000+ orthophoto pairs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 08:36:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444377#M25364</guid>
      <dc:creator>MihaKlemencic</dc:creator>
      <dc:date>2016-01-18T08:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Minus Tool</title>
      <link>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444378#M25365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.5pt; font-family: Helvetica, sans-serif;"&gt;Just a small question... do you need them as separated files &lt;/SPAN&gt;or is merging them into a single raster an option before you apply the minus tool?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 13:15:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/minus-tool/m-p/444378#M25365</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-18T13:15:16Z</dc:date>
    </item>
  </channel>
</rss>

