<?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: mosaicking only certain files within a folder using Python loop in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618157#M20528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can iterate your variable numbers:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy.sa import*
import time

start_time = time.clock()
env.workspace = "G:/Eck_health_disease/spatial data/WorldClimate data/test"
arcpy.env.overwriteOutput = True
print "Processing Mosaic"
print "Number of tiles to be Mosaicked:" + str(len(ImgList))
Katanga_poly = r"G:\Eck_health_disease\spatial data\COD_adm_shp\DRC_Katanga.shp"
for i in range(1,19):
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp; ImgList = arcpy.ListRasters("bio"+str(i)+"*")&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy.MosaicToNewRaster_management(ImgList, env.workspace, "bio"+str(i)+"_mos.tif",&amp;nbsp; pixel_type="32_BIT_FLOAT", cellsize="", number_of_bands="1", mosaic_method="", mosaic_colormap_mode="MATCH")&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; arcpy.Clip_management("bio"+str(i)+"_mos.tif","21.7447528839 -13.4556760785 30.7780862172 -4.99734274513", "bio"+str(i)+"_mos_Kat.tif", Katanga_poly, "#", "ClippingGeometry", "MAINTAIN_EXTENT")
&amp;nbsp;&amp;nbsp; arcpy.RasterToASCII_conversion("bio"+str(i)+"_mos_Kat.tif", "bio"+str(i)+"_mos_Kat.asc")
print "Task Completed!"
print time.clock() - start_time, "seconds"

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:24:41 GMT</pubDate>
    <dc:creator>FC_Basson</dc:creator>
    <dc:date>2021-12-12T02:24:41Z</dc:date>
    <item>
      <title>mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618156#M20527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I have a folder with filenames bio1_36.tif, bio1_37.tif, bio2_36_tif, bio2_37.tif, and so on. There are 19 bio variables and 36 and 37 at the end refer to the tile numbers. My goal is to mosaic the two tiles for each variable, clip to the size of a polygon layer called “Katanga” and convert the final output to ascii format. I’ve been using the code below however this will only generate the correct output if the two tiles for the same bio variable are specified in the code or these two files are the only input in the workspace folder.&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;How can I do the above procedure in a recursive manner for each bio variable, i.e. setting up a loop?&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;This way I don’t have to create separate folders for each bio variable or specify them in the code.&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I am new to Python.&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Below is the code I’ve been using (note: "test" folder only contains one bio variable with the two tiles):&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #242729; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; arcpy&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;from&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; arcpy &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; env&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;from&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;sa &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;*&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; time&lt;BR /&gt;&lt;BR /&gt;start_time &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; time&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;clock&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;env&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;workspace &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"G:/Eck_health_disease/spatial data/WorldClimate data/test"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;env&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;overwriteOutput &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;True&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;ImgList&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;ListRasters&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;print&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"Processing Mosaic"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;print&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"Number of tiles to be Mosaicked:"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; str&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;len&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;ImgList&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;))&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;MosaicToNewRaster_management&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;ImgList&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; env&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;workspace&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"bio1_mos.tif"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&amp;nbsp; pixel_type&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"32_BIT_FLOAT"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; cellsize&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;""&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; number_of_bands&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"1"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; mosaic_method&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;""&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; mosaic_colormap_mode&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"MATCH"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Katanga_poly&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"G:/Eck_health_disease/spatial data/COD_adm_shp/DRC_Katanga.shp"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Clip_management&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"bio1_mos.tif"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"21.7447528839 -13.4556760785 30.7780862172 -4.99734274513"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"bio1_mos_Kat.tif"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Katanga_poly&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"#"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"ClippingGeometry"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"MAINTAIN_EXTENT"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;RasterToASCII_conversion&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"bio1_mos_Kat.tif"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"bio1_mos_Kat.asc"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;print&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"Task Completed!"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;print&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; time&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;clock&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;-&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; start_time&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #7d2727;"&gt;"seconds"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jun 2016 06:23:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618156#M20527</guid>
      <dc:creator>KemalGokkaya</dc:creator>
      <dc:date>2016-06-19T06:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618157#M20528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can iterate your variable numbers:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy.sa import*
import time

start_time = time.clock()
env.workspace = "G:/Eck_health_disease/spatial data/WorldClimate data/test"
arcpy.env.overwriteOutput = True
print "Processing Mosaic"
print "Number of tiles to be Mosaicked:" + str(len(ImgList))
Katanga_poly = r"G:\Eck_health_disease\spatial data\COD_adm_shp\DRC_Katanga.shp"
for i in range(1,19):
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp; ImgList = arcpy.ListRasters("bio"+str(i)+"*")&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy.MosaicToNewRaster_management(ImgList, env.workspace, "bio"+str(i)+"_mos.tif",&amp;nbsp; pixel_type="32_BIT_FLOAT", cellsize="", number_of_bands="1", mosaic_method="", mosaic_colormap_mode="MATCH")&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; arcpy.Clip_management("bio"+str(i)+"_mos.tif","21.7447528839 -13.4556760785 30.7780862172 -4.99734274513", "bio"+str(i)+"_mos_Kat.tif", Katanga_poly, "#", "ClippingGeometry", "MAINTAIN_EXTENT")
&amp;nbsp;&amp;nbsp; arcpy.RasterToASCII_conversion("bio"+str(i)+"_mos_Kat.tif", "bio"+str(i)+"_mos_Kat.asc")
print "Task Completed!"
print time.clock() - start_time, "seconds"

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:24:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618157#M20528</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T02:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618158#M20529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for the suggestion. However, this code generate only&lt;/P&gt;&lt;P&gt;one mosaic file named *bio1_mos.tif *instead of two when I tried on a test&lt;/P&gt;&lt;P&gt;folder which contained bio1_36.tif, bio1_37.tif, bio2_36_tif,&lt;/P&gt;&lt;P&gt;bio2_37.tif files.&lt;/P&gt;&lt;P&gt;And, all of these files were used in the mosaicking. What I want is to&lt;/P&gt;&lt;P&gt;mosaic only bio1_36.tif, bio1_37.tif and create an output named *bio1_mos.tif.&lt;/P&gt;&lt;P&gt;*Then, mosaic bio2_36_tif, bio2_37.tif and generate an output file named&lt;/P&gt;&lt;P&gt;bio2_mos.tif and do this for all 19 variables.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kemal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 07:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618158#M20529</guid>
      <dc:creator>KemalGokkaya</dc:creator>
      <dc:date>2016-06-20T07:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618159#M20530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also been working on the code below. Maybe you can help me with this&lt;/P&gt;&lt;P&gt;if it makes sense. I could get it to generate the bio1_mos and bio2_mos tif&lt;/P&gt;&lt;P&gt;files but the processing of mosic to new raster is giving error and the&lt;/P&gt;&lt;P&gt;files are empty. Please note that "test" folder contains bio1_36 and&lt;/P&gt;&lt;P&gt;bio2_36.tif files. test2 file contains bio1_37 and bio2_37.tif files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy, os, sys&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;import time&lt;/P&gt;&lt;P&gt;start_time = time.clock()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;this will overwrite output. Important in testing codes&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;activate the spatial analyst extention of ArcGIS&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;arcpy.CheckOutExtension("Spatial")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;path = "G:/Eck_health_disease/spatial data/WorldClimate data/test"&lt;/P&gt;&lt;P&gt;bio36 = &lt;/P&gt;&lt;P&gt;f=[]&lt;/P&gt;&lt;P&gt;for fname in bio36:&lt;/P&gt;&lt;P&gt;    with open(os.path.join(path, fname), 'r') as fr:&lt;/P&gt;&lt;P&gt;        f.append(fr.readlines())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;path = "G:/Eck_health_disease/spatial data/WorldClimate data/test2"&lt;/P&gt;&lt;P&gt;bio37 = &lt;/P&gt;&lt;P&gt;f=[]&lt;/P&gt;&lt;P&gt;for fname in bio37:&lt;/P&gt;&lt;P&gt;    with open(os.path.join(path, fname), 'r') as fr:&lt;/P&gt;&lt;P&gt;        f.append(fr.readlines())&lt;/P&gt;&lt;P&gt;newList=[]&lt;/P&gt;&lt;P&gt;mosaic =[]&lt;/P&gt;&lt;P&gt;basename=[]&lt;/P&gt;&lt;P&gt;##counter = 1&lt;/P&gt;&lt;P&gt;for i in range(len(bio36)):&lt;/P&gt;&lt;OL&gt;&lt;OL&gt;&lt;LI level="2" type="ol"&gt;&lt;P&gt;   for j in range(len(bio37)):&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;&lt;P&gt;        try:&lt;/P&gt;&lt;P&gt;            workspace = arcpy.env.workspace =&lt;/P&gt;&lt;P&gt;"G:/Eck_health_disease/spatial data/WorldClimate data/bio_mos"&lt;/P&gt;&lt;P&gt;            basename = os.path.basename(bio36&lt;I&gt;).split("_")[0]&lt;/I&gt;&lt;/P&gt;&lt;OL&gt;&lt;OL&gt;&lt;LI level="2" type="ol"&gt;&lt;P&gt;           r1 = arcpy.sa.Raster(i)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ol"&gt;&lt;P&gt;           r2 = arcpy.sa.Raster(os.path.join(bio37, basename +&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;&lt;P&gt;"_37.tif"))&lt;/P&gt;&lt;P&gt;            newList = [bio36&lt;I&gt;, bio37&lt;I&gt;]&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;            list = ";".join(newList)&lt;/P&gt;&lt;OL&gt;&lt;OL&gt;&lt;LI level="2" type="ol"&gt;&lt;P&gt;           rasterList = arcpy.ListRasters(NewList)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ol"&gt;&lt;P&gt;           Fn = raster[0:1]&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;&lt;P&gt;            outname = basename + "_mos.tif"&lt;/P&gt;&lt;P&gt;            mosaic =&lt;/P&gt;&lt;P&gt;arcpy.MosaicToNewRaster_management(list,workspace,outname,"","32_BIT_FLOAT",&lt;/P&gt;&lt;P&gt;"", "1", "","MATCH")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            mosaic.save(os.path.join(workspace,outname))&lt;/P&gt;&lt;P&gt;        except:&lt;/P&gt;&lt;P&gt;            print "Mosaic failed."&lt;/P&gt;&lt;P&gt;            print arcpy.GetMessages()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print "Task Completed!"&lt;/P&gt;&lt;P&gt;print time.clock() - start_time, "seconds"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 07:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618159#M20530</guid>
      <dc:creator>KemalGokkaya</dc:creator>
      <dc:date>2016-06-20T07:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618160#M20531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've updated my code to search all the bioX rasters for each iteration.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 07:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618160#M20531</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-06-20T07:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618161#M20532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! That does the trick. Can you tell me what "*" does in the updated line &lt;SPAN class="string" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: blue;"&gt;"bio"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;+str(i)+&lt;/SPAN&gt;&lt;SPAN class="string" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: blue;"&gt;"*" &lt;/SPAN&gt;?&lt;/P&gt;&lt;P&gt;Also, range (1,19) goes from 1 to 18 so for 19 variables it needs to be (1,20). I figured that out when I was working&lt;/P&gt;&lt;P&gt;with a test folder with four files.&lt;/P&gt;&lt;P&gt;Thanks again! It saved a lot of time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2016 14:12:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618161#M20532</guid>
      <dc:creator>KemalGokkaya</dc:creator>
      <dc:date>2016-06-21T14:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618162#M20533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The "*" is a wildcard character that basically means any character after the "bio" string, so for this example the ListRasters function will be filtered to all datasets starting with "bio" and the selected parameter number e.g. all "bio1" rasters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 05:42:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618162#M20533</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-06-22T05:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: mosaicking only certain files within a folder using Python loop</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618163#M20534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the explanation. Now, I can use it in other situations. Best,&lt;/P&gt;&lt;P&gt;Kemal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 15:13:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/mosaicking-only-certain-files-within-a-folder/m-p/618163#M20534</guid>
      <dc:creator>KemalGokkaya</dc:creator>
      <dc:date>2016-06-27T15:13:50Z</dc:date>
    </item>
  </channel>
</rss>

