Select to view content in your preferred language

Create a raster from a raster function:"Raster_calculator_function"

2044
10
08-28-2023 12:36 AM
Labels (2)
AlexanderZhang
Occasional Contributor

Hi All,

  Recently i develop a gis app with Navtive Maps SDK 200.1, i want to apply a raster function(Raster_calculator_function) on a raster file, but it doesn't work, so i wander whether i can use  the function:"Con()" in the expression statement as following:

string theJSON_String =
@"{
""raster_function_arguments"":
{
""expression"":{ ""string"":""Con(r1>r2,0,1)"",""name"":""expression"",""type"":""Raster_function_variable""},
""raster_names"":{ ""name"":""raster_names"",""type"":""Raster_function_variable""},
""raster_names"":{ ""name"":""raster_names"",""string_array"":[""r1"",""r2""],""type"":""Raster_function_variable""},
""r1"":{ ""name"":""r1"",""is_raster"":true,""type"":""Raster_function_variable""},
""r2"":{ ""name"":""r2"",""is_raster"":true,""type"":""Raster_function_variable""},
""type"":""Raster_function_arguments""
},
""raster_function"":{ ""type"":""Raster_calculator_function""},
""type"":""Raster_function_template""
}";

// Create a raster function from the JSON string using the static/Shared method called: RasterFunction.FromJson(json as String)
RasterFunction myRasterFunction = RasterFunction.FromJson(theJSON_String);

 Esri.ArcGISRuntime.Rasters.RasterFunction(path as String)

// Get the raster function arguments
RasterFunctionArguments myRasterFunctionArguments = myRasterFunction.Arguments;

// Get the list of names from the raster function arguments
IReadOnlyList<string> myRasterNames = myRasterFunctionArguments.GetRasterNames();

// Apply the first raster name and image service raster in the raster function arguments
myRasterFunctionArguments.SetRaster(myRasterNames[0], raster1);
myRasterFunctionArguments.SetRaster(myRasterNames[1], raster2);

var layer = new RasterLayer(new Raster(myRasterFunction));

Tags (1)
0 Kudos
10 Replies
williambohrmann3
Esri Contributor

Oh ok. If you're able to zip your raster files and code, my email is wbohrmann@esri.com but I understand if its too large to share.

I see Mike responded to your other problem.

0 Kudos