0

I'm attempting to complete a batch mosaic operation in ArcMap 10.4.1 Python window. I need to run the Mosaic tool about 80 times for sets of three rasters. Basically I want the second and third raster to mosaic to the first raster with all of the default mosaic properties. My code to do this is pasted below, but after playing around with the inputs for the Mosaic Management tool I keep getting back a parsing error SyntaxError in the line where the Mosaic operation occurs.

# Name: Batch Extract by Mask

... # Description: Iteratively calculate extracts the flow velocity of cells
... # Requires spatial analyst
... # MAKE SURE RASTERS FOR Connectivity ARE LOADED IN THE MXD TABLE OF CONTENTS
...  
... # Import system modules
... import arcpy
... from arcpy import env
... from arcpy.sa import *    
... import math

... # Set environment settings

... env.workspace = "C:\Subbasin Connectivity Flow Time"

... # Check the ArcGIS Spatial Analyst extension license

... arcpy.CheckOutExtension("Spatial")

... count = 1

... # Run for each raster in the directory 

... while count < 80:
... # Execute times flow direction calculation
...     name1 = "Day72Subbasin" + str(count) + " Bin 1.tif"      
...     Bin1 = Raster(name1)
...     name2 = "Day72Subbasin" + str(count) + " Bin 2.tif" 
...     Bin2 = Raster(name2)
...     name3 = "Day72Subbasin" + str(count) + " Bin 3.tif" 
...     Bin3 = Raster(name3)
...     arcpy.Mosaic_management(Bin2;Bin3,Bin1,"LAST","FIRST","0", "", "NONE", "", "")
...     count = count + 1 
4
  • I believe you need to pass those first few parameters in double quotes. Try arcpy.Mosaic_management("{}".format(Bin2;Bin3),"{}".format(Bin1),"LAST","FIRST","0", "", "NONE", "", "")
    – Andy
    Feb 13, 2019 at 19:26
  • What is the precise wording of the error?
    – PolyGeo
    Feb 13, 2019 at 20:30
  • code Parsing error SyntaxError: invalid syntax (line 39) @PolyGeo Feb 14, 2019 at 13:20
  • Thanks for your comment, @Andy. Unfortunately that is giving the same error in line 39. Feb 14, 2019 at 13:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.