<?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: merge rasters Mosaic to New Raster in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/m-p/88309#M6872</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would be helpful if you could pinpoint the problem or supply the error message...&lt;/P&gt;&lt;P&gt;Although line 20 looks suspect. especially the "&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;l&lt;/SPAN&gt;", it only appears in line 09 that i can see, and would use the last found raster name in that set to parse for all 46 names in your array.. The way it is written it would seem that it would continually overwrite your output file for each of the 46 iterations&lt;/P&gt;&lt;P&gt;it may also be that you need to change your input rasters from:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;Raster(tile1&lt;H&gt;);Raster(tile2&lt;H&gt;)&lt;/H&gt;&lt;/H&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;to&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px; background-color: #f6f6f6; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;[Raster(tile1&lt;H&gt;), Raster(tile2&lt;H&gt;)]&lt;/H&gt;&lt;/H&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Dec 2014 14:05:19 GMT</pubDate>
    <dc:creator>DallasShearer</dc:creator>
    <dc:date>2014-12-03T14:05:19Z</dc:date>
    <item>
      <title>merge rasters Mosaic to New Raster</title>
      <link>https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/m-p/88308#M6871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;Hi Python Users,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;I got stuck with my code trying to merge modis rasters (in tiff format) using Mosaic to New Raster. Any help will be much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;I have&amp;nbsp; time series NDVI rasters from MODIS data for 2014 for two tiles located in separate directory. What I would like to achieve is to automate the merging of the times series NDVI rasters using the Mosaic to New Raster tool in arcpy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;MOD_h26v06_2014001_ndvi.tif merged with MOD_h27v06_2014001.tif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;MOD_h26v06_2014297_ndvi.tif merged with MOD_h27v06_2014297.tif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;Any help/suggestion is very much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;Below is the code that I am working on.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;-Leo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")

raster1 = 'path/toRaster1'
arcpy.env.workspace = raster1
tile1 = [os.path.join(raster1, l) for l in arcpy.ListRasters("*2014*", "TIF")]

raster2 = 'path/toRaster2'
arcpy.env.workspace = raster2
tile2 = [os.path.join(raster2, r) for r in arcpy.ListRasters("*2014*", "TIF")]

out_ws = 'path/Out_rast'

# (input rasters,outputloc,name w/ ext, coor, pixeltype, cellsize, #of bands
# mosaic method, mosaic color map)
for h in range(0,46):
&amp;nbsp;&amp;nbsp;&amp;nbsp; parse = l[18:25]
&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = "modis_evi_" + parse + ".tif"
&amp;nbsp;&amp;nbsp;&amp;nbsp; mosaic = arcpy.MosaicToNewRaster_management(Raster(tile1&lt;H&gt;);Raster(tile2&lt;H&gt;), out_ws, filename, "", "16_BIT_SIGNED", "", "1", "LAST","FIRST")&lt;/H&gt;&lt;/H&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mosaic&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:22:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/m-p/88308#M6871</guid>
      <dc:creator>Leo_KrisPalao</dc:creator>
      <dc:date>2021-12-10T23:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: merge rasters Mosaic to New Raster</title>
      <link>https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/m-p/88309#M6872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would be helpful if you could pinpoint the problem or supply the error message...&lt;/P&gt;&lt;P&gt;Although line 20 looks suspect. especially the "&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;l&lt;/SPAN&gt;", it only appears in line 09 that i can see, and would use the last found raster name in that set to parse for all 46 names in your array.. The way it is written it would seem that it would continually overwrite your output file for each of the 46 iterations&lt;/P&gt;&lt;P&gt;it may also be that you need to change your input rasters from:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;Raster(tile1&lt;H&gt;);Raster(tile2&lt;H&gt;)&lt;/H&gt;&lt;/H&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;to&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px; background-color: #f6f6f6; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;[Raster(tile1&lt;H&gt;), Raster(tile2&lt;H&gt;)]&lt;/H&gt;&lt;/H&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 14:05:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/m-p/88309#M6872</guid>
      <dc:creator>DallasShearer</dc:creator>
      <dc:date>2014-12-03T14:05:19Z</dc:date>
    </item>
  </channel>
</rss>

