<?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: Band Composite failing when using arcpy in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155135#M52980</link>
    <description>&lt;P&gt;&lt;EM&gt;for img in Input:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This does nothing.&amp;nbsp; You need ListRasters to act on the workspace.&lt;/P&gt;&lt;P&gt;And this line will accomplish nothing unless the previous line provides a raster&lt;/P&gt;&lt;P&gt;&lt;EM&gt;name = os.path.join(Output, img[0].split("_")[0] + ".tif")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You would be better off providing the raster bands you need and providing an output filename.&lt;/P&gt;&lt;P&gt;If you need to automate this for other folders, can you provide the rules that you will use to assemble the needed bands.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2022 05:57:32 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-03-18T05:57:32Z</dc:date>
    <item>
      <title>Band Composite failing when using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155128#M52977</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have multiple NetCDF files which were converted into tiff&amp;nbsp;files using the tools&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Make NetCDF Raster Layer&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Copy Raster&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;tool in ArcGIS Pro 2.6. As output, I now have multiple tiff&amp;nbsp;files in a folder with many bands inside the tiff files. Here is a screenshot for reference.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VikhyatGupta3_0-1647575148007.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36690iEE4E44437462D4B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VikhyatGupta3_0-1647575148007.png" alt="VikhyatGupta3_0-1647575148007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As I have multiple tiff files of such kind, I am now trying to come up with a python script that can composite only certain bands.&lt;/P&gt;&lt;P&gt;So if the total number of bands in a tiff file is 365 I only want to composite Band_167 to Band_193.&lt;/P&gt;&lt;P&gt;Here is the snippet that I have worked out so far however, it gives me an error :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to create raster dataset
Failed to execute (CompositeBands).&lt;/PRE&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

arcpy.env.workspace = r'C:\Vikhyat\Test'
Input = arcpy.env.workspace
Output = r'C:\Vikhyat\Data\Stack'

for img in Input:
    name = os.path.join(Output, img[0].split("_")[0] + ".tif")
    arcpy.CompositeBands_management('Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_167;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_168;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_169;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_170', name)
print('Finished')


 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to use &lt;SPAN&gt;arcpy.CompositeBands_management on individual bands which are in tiff format and it worked successfully.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hence, any inputs on what I might be missing would be helpful.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 03:55:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155128#M52977</guid>
      <dc:creator>wizgis</dc:creator>
      <dc:date>2022-03-18T03:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Band Composite failing when using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155135#M52980</link>
      <description>&lt;P&gt;&lt;EM&gt;for img in Input:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This does nothing.&amp;nbsp; You need ListRasters to act on the workspace.&lt;/P&gt;&lt;P&gt;And this line will accomplish nothing unless the previous line provides a raster&lt;/P&gt;&lt;P&gt;&lt;EM&gt;name = os.path.join(Output, img[0].split("_")[0] + ".tif")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You would be better off providing the raster bands you need and providing an output filename.&lt;/P&gt;&lt;P&gt;If you need to automate this for other folders, can you provide the rules that you will use to assemble the needed bands.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 05:57:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155135#M52980</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-03-18T05:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Band Composite failing when using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155187#M52986</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for suggesting to use the list raster's method, it worked and I was also able to format output file name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 12:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155187#M52986</guid>
      <dc:creator>wizgis</dc:creator>
      <dc:date>2022-03-18T12:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Band Composite failing when using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155193#M52987</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ListRasters method worked however, the issue that I am having now is that output is getting overwritten as I had hardcoded which raster file bands I want to composite. Here is the snippet for reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use only Band name like Band_167, Band_168 etc however, it gives me an error :&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure what exactly to put in parameters so that it composite individual file bands.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR 000732: Input Rasters: Dataset Band_167 does not exist or is not supported&lt;/PRE&gt;&lt;LI-CODE lang="python"&gt; arcpy.CompositeBands_management('Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_167;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_168;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_169;Rainfall__Clim_Pred_LRF_New_RF25_IMD0p252001.tif/Band_170', name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 12:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155193#M52987</guid>
      <dc:creator>wizgis</dc:creator>
      <dc:date>2022-03-18T12:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Band Composite failing when using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155307#M53006</link>
      <description>&lt;P&gt;You still need the full path to the raster and/or set the environment to the folder that contains the rasters as you did previously.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 17:32:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/band-composite-failing-when-using-arcpy/m-p/1155307#M53006</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-03-18T17:32:04Z</dc:date>
    </item>
  </channel>
</rss>

