AnsweredAssumed Answered


Question asked by lkoumis on Jul 31, 2018
Latest reply on Aug 1, 2018 by lkoumis

I want to replicate the behavior of Arcmap analysis tools/overlay/intersect tool by using SPATIAL_REL_INTERSECTS.

In that tool, when you specified two polygon classes, it doesn't matter the order, the area of intersection is the same.


I want the users to be able to use any two polygon classes to run the intersect tool to get the intersected area.


I am using the script below. If I switch the first layer with the second the results are different. Why? The intersected area should be the same regardless which layer is specified as first or second. Thanks.

var firstgraphics = [];
            var features = [];
            array.forEach(, function (feature) {

            var secondgraphics = [];
            array.forEach(, function (feature1) {

            var queryTask = new esri.tasks.QueryTask(firstlayer.url);
            queryTask.on("error", this.queryTaskErrorHandler);
            for (j = 0; j < secondgraphics.length; j++) {
              query = new esri.tasks.Query();
              query.geometry = secondgraphics[j];
              query.returnGeometry = true;
              query.where = "1=1";
              query.outFields = ["*"];
              query.outSpatialReference =;
              query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
              queryTask.execute(query, function (results) {
                  for (i = 0; i < results.features.length; i++) {
                   // thefeatureSet =  results.results[i];
                    var graphic = new esri.Graphic(results.features[i].geometry, inter_symbol);