1

I'm trying to use

MosaicToNewRaster

but a lot of errors are appears. One of them is:

ERROR 000732: Output Location: Dataset results does not exist or is not supported

My code is:

import arcpy

from arcpy import env env.workspace = "C:\Users\user\Documents\ArcGIS\teste"

<p>arcpy.MosaicToNewRaster_management("SG-21-Z-D.tif;SG-22-Y-C.tif","C:\Users\user\Documents\ArcGIS","marco.tif","","1_BIT","0.000833333353511989","1")</p>

Should I change something?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

1 Answers1

4

Your workspace is missing the r before the path or you can replace one backslash \ with two backslashes \\ or you can replace the backslash \ with a forward slash /. You can adjust your code based on the following example:

import arcpy
from arcpy import env

# Set the current workspace
ws = env.workspace = r"F:\Ahmad\Test\DEM"

# Get a list of raster from the workspace
rasterlist = arcpy.ListRasters()
print(rasterlist)

# OR you can pass your target raster data to a list
# rasterlist = [SG-21-Z-D.tif,SG-22-Y-C.tif]

# Execute MosaicToNewRaster_management() tool
mosaic = arcpy.MosaicToNewRaster_management(rasterlist,ws,'MosaicFinal.tif','',pixel_type='16_BIT_SIGNED',number_of_bands=1)

Check the Mosaic To New Raster help for more information.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
ahmadhanb
  • 40,826
  • 5
  • 51
  • 105