AnsweredAssumed Answered

Geoprocessing service returning wrong raster

Question asked by adepottey on Jun 9, 2014
Latest reply on Jun 11, 2014 by adepottey
I have created a geoprocessing service that adds two TIF rasters in a specified area of interest, then copies this result to a PNG raster and returns it.  It works as expected when I execute the tool from ArcMap, but when I execute the tool on ArcGIS Server (v10.1.0), it returns the TIF version of the raster.  I can see the PNG is sitting in the scratch directory, but for some reason it's not being returned.

Can anyone spot a mistake in my code below?

import os import arcpy from arcpy import env from arcpy.sa import *  # note: we're using os.path.join as a workaround for broken data source errors debug_features = os.path.join('C:\Raster\scripts\Temp.gdb\simple')  # Set this to the folder containing all rasters workspace = "C:\Raster\Data"  try:     # Check out Spatial Analyst License     arcpy.CheckOutExtension("Spatial")      env.workspace = workspace          # Get parameters     aoi_layer = arcpy.MakeFeatureLayer_management(debug_features,'in_memory\features')     raster_1 = "tmax_1.tif"     raster_2 = "tmax_2.tif"          # Extract only the area under the feature layer     aoi_raster_1 = ExtractByMask(raster_1,aoi_layer)     aoi_raster_2 = ExtractByMask(raster_2,aoi_layer)          # Add two rasters     out_raster = aoi_raster_1 + aoi_raster_2      # Copy to png     name = arcpy.CreateUniqueName("rastermath_output.png", arcpy.env.scratchFolder)     arcpy.CopyRaster_management(out_raster, name,"DEFAULTS",                            "","","","","16_BIT_UNSIGNED", "ScalePixelValue")      # Set output param     arcpy.SetParameterAsText(0, name)  except Exception as e:     arcpy.AddError(str(e))  finally:     arcpy.Delete_management('in_memory')


I cannot use the original TIF in a javascript MapImageLayer, so any advice or workarounds would be much appreciated.

Outcomes