Select to view content in your preferred language

Using Make Layer works in Pro but not in a GP tool

293
2
Jump to solution
11-08-2024 12:25 PM
DougBrowning
MVP Esteemed Contributor

Been testing an infinite number of combinations the last few days and still cannot get it. 

This all works great in Pro/PyScripter, and it does publish, but when running as a GP tool I get the message  ERROR 003401: Invalid or unsupported input raster. Failed to execute (MakeRasterLayer).

Pro 3.1 and Server 11.3

RAPTrendRaster = arcpy.ia.GenerateTrendRaster("yearsRaster", "StdTime", runIndicators, "MANN-KENDALL", None, "DATA", None, "", "RMSE", "NO_R2", "NO_SLOPEPVALUE", "")

oneIndLayer = arcpy.md.MakeMultidimensionalRasterLayer(RAPTrendRaster, "oneInd", indToMap)[0]
arcpy.AddMessage(oneIndLayer)   # nothing prints here on the server but in Pro I get <MappingLayerObject object at 0x0000021636EA4D20>


pvalLayer = arcpy.management.MakeRasterLayer(oneIndLayer, "RAPTrendRaster_pval", band_index=[2])[0]

The last line fails with: Invalid or unsupported input raster.  

I run it all in PyScripter and then I can do either of these and it works.

pvalLayer = arcpy.management.MakeRasterLayer(oneIndLayer, "RAPTrendRaster_pval", band_index=[2])[0]

or

pvalLayer = arcpy.management.MakeRasterLayer("oneInd", "RAPTrendRaster_pval", band_index=[2])[0]

And it works just fine.

My guess is its either not storing the layer file at all or it is not pathing right.  Of course its remapping some of my vars but its just repalcing ESRI_Var and then that gets oneIndLayer

I guess my question is how do I use layer files in a GeoProcessing tool?  Cannot find anything about it.

thanks a lot

1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

After many hours I figured out that the MakeRasterLayer just plain will not take input from MakeMultidimensionalLayer - even though it works in Pro, it will not on the server.

So I changed to 
TrendRaster_pval = arcpy.ia.ExtractBand("oneInd", [2])

and that worked.  But did not in Pro.  So weird.

The server seems to not handle temp in memory layers the same way.  It gets lost.  Next had the same issue with a polygon input from the GP widget.  There I must save it to scratch GDB or it will never draw.  But that works fine in Pro.

Hopes that helps someone.  GP tools are such a mystery.

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

Is maybe the help wrong.  Why is a temp layer getting a path and file extension?

From the help

# Import system modules
import arcpy

# Define input parameters
in_multidimensional_raster = r"C:\data\MD_Ocean_data.crf"
out_multidimensional_raster_layer = r"C:\data\Temp_slice.crf"
variables = "water_temp"
dimension_def = "BY_VALUE"
dimension_values = "StdZ -50;StdZ -100"
template = "120.084279939743 0.914964278021376 139.524470909773 21.1231086159414"

#Execute

arcpy.md.MakeMultidimensionalRasterLayer(
	in_multidimensional_raster, out_multidimensional_raster_layer, variables, 
	dimension_def, dimension_values, template)
0 Kudos
DougBrowning
MVP Esteemed Contributor

After many hours I figured out that the MakeRasterLayer just plain will not take input from MakeMultidimensionalLayer - even though it works in Pro, it will not on the server.

So I changed to 
TrendRaster_pval = arcpy.ia.ExtractBand("oneInd", [2])

and that worked.  But did not in Pro.  So weird.

The server seems to not handle temp in memory layers the same way.  It gets lost.  Next had the same issue with a polygon input from the GP widget.  There I must save it to scratch GDB or it will never draw.  But that works fine in Pro.

Hopes that helps someone.  GP tools are such a mystery.

0 Kudos