lundi 23 mars 2015

Issue with ESRI API RasterFunction Arithmetic


I am not sure if this is the right place, but I'll post here anyway. Anyway as the title says I would like some help with this code block that I am writing. Basically what I am trying to do is create an application that can do simple map algebra using two rasters. This is accomplished using ESRI's API. I will include the code block at the bottom. It is filled with comments about the code and where the issue is occurring. Basically the issue I am running into is that after reclassification of the two rasters is complete, I am trying to multiply them together using the RasterFunction = "Arithmetic". The issue is that they are not multiplying and I get an error that reads: "{"error":{"code":400,"message":"Invalid or missing input parameters.","details":[]}}" If someone could take a look at my code block and may point me in the right direction or give me guidance that would be great! Also note that I am not an expert programmer by any means so this is a very rough code block. Code Block:



require(["dojo/parser",
"esri/layers/ArcGISImageServiceLayer", "esri/layers/ImageServiceParameters",
"esri/layers/RasterFunction", "esri/map", "dijit/layout/BorderContainer",
"dijit/layout/ContentPane"],
function(parser, ArcGISImageServiceLayer, ImageServiceParameters, RasterFunction, Map) {
parser.parse();

var map = new Map("map", {
basemap:"topo",
center:[-84.25, 42.6],
zoom: 11
});
////parameters for reclassifying DEM
var params = new ImageServiceParameters(); //creates new ImageServiceParameter object
var reclass_dem = new RasterFunction(); // creates new RasterFunction called reclass_dem
reclass_dem.functionName = "Remap"; //sets reclass_dem function to "Remap"
var functionArguments_dem = {}; //creates object called functionArguments_dem
functionArguments_dem.InputRanges = [802.2,900]; //creates input range function argument for reclass_dem
functionArguments_dem.OutputValues = [1]; //creates output values function argument for reclass_dem
functionArguments_dem.AllowUnmatched = false; //creates no data values for any values outside input range; funciton argument

reclass_dem.functionArguments = functionArguments_dem; //sets functionArguments_dem to reclass_dem's function arguments

//reclass_dem.variableName = "Raster"; //sets reclass_dem object variable to "Raster" type
params.renderingRule = reclass_dem; //sets params object renderingRule to reclass_dem function arguments

//parameters for reclassifying LandCover
var params_land = new ImageServiceParameters(); //creates new ImageServiceParameter object
var reclass_landcov = new RasterFunction(); //creates new RasterFunction called reclass_landcov
reclass_landcov.functionName = "Remap"; //sets reclass_landcov function to "Remap"
var functionArguments_lc = {}; //creates object called functionArguments_lc
functionArguments_lc.InputRanges = [10,30]; //creates input range function argument for reclass_landcov
functionArguments_lc.OutputValues = [1]; //creates output values function argument for reclass_landcov
functionArguments_lc.AllowUnmatched = false; //creates no data values for any values outside input range; funciton argument

reclass_landcov.functionArguments = functionArguments_lc; //sets functionArguments_lc to reclass_landcov's function arguments

//reclass_landcov.variableName = "Raster"; //sets reclass_landcov object variable to "Raster" type
params_land.renderingRule = reclass_landcov; //sets params object renderingRule to reclass_landcov function arguments


//STUCK HERE! RECLASSIFIED RASTERS WON'T
//MULTIPLY TOGETHER; GIVE ERROR/WONT DISPLAY IMAGE
//Multiply rasters
var params_suit = new ImageServiceParameters(); //creates new ImageServiceParameter object
var suit = new RasterFunction(); //creates new RasterFunction called suit
suit.functionName = "Arithmetic"; //sets reclass_landcov function to "Arithmetic"
var functionArguments_alge = {}; //creates object called functionArguments_alge
functionArguments_alge.Raster = "params_land"; //renderRule object for landcover reclass
functionArguments_alge.Raster2 = "params"; //renderRule object for elevation reclass
functionArguments_alge.Operation = 3; //multiplication operation (1 = +)(2 = -)(3 = *)

suit.functionArguments = functionArguments_alge; //sets functionArguments_lc to suit's function arguments
params_suit.renderingRule = suit; //sets params object renderingRule to suit function arguments


var dem = new ArcGISImageServiceLayer("http://ift.tt/1BcETKW",{imageServiceParameters:params_suit});
var landcov = new ArcGISImageServiceLayer("http://ift.tt/19MgTaX", {imageServiceParameters:params_suit});
map.addLayers([dem,landcov]);
dojo.connect(map, 'onLoad', function(theMap) {
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
});
});




Aucun commentaire:

Enregistrer un commentaire