Geoprocessing service returning wrong raster

2179
1
Jump to solution
06-09-2014 10:26 AM
AshleyDePottey
New Contributor II
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.
0 Kudos
1 Solution

Accepted Solutions
AshleyDePottey
New Contributor II
After doing more research, I discovered that rasters are always returned as TIFs from geoprocessing services.  Instead, I enabled the capability to view results as a map service on the geoprocessing service, which gives me the functionality I was looking for.

View solution in original post

0 Kudos
1 Reply
AshleyDePottey
New Contributor II
After doing more research, I discovered that rasters are always returned as TIFs from geoprocessing services.  Instead, I enabled the capability to view results as a map service on the geoprocessing service, which gives me the functionality I was looking for.
0 Kudos