AnsweredAssumed Answered

What values should I use in Project Parameters for Geometry Service?

Question asked by janiceb on Apr 22, 2015
Latest reply on Apr 22, 2015 by tsellste

I am using a combination of the measurement widget and Geometry Service for measuring distances and areas. I am getting different results from each method when trying to get the area of a polygon. I have read in earlier posts that I should project my polygon before doing the calculation. I added the project command and I am still getting different results from each method, measurement widget vs. geometry service. My map is in Web Mercator Auxiliary Sphere and my area of interest is in Washington State Plane North. I am using two functions to do the actual work and can see that the polygon is being projected. My issue is possibly the values that I am using in the project parameters... I have tried many different combinations for outSR and transformation. It appears that the measurement widget and geometry service area measures are off by the same amount no matter which combinations I have tried. The code for my two functions is below. GetAreaAndDistances is called when the final vertex in the polygon is drawn and getProjectedArea is called on geometry service project-complete.

 

What am I doing wrong? Should I be able to get the same area measurement from the measurement widget and the geometry service for the same polygon?

 

by the way, I am using 3.13.

 

Thanks,

Janice.

 

function GetAreaAndDistances(evtObj) {
    ///********************************************************************************************
    ///********************************************************************************************
    ///FROM:: https://developers.arcgis.com/en/javascript/jssamples/util_measurepoly.html
    ///********************************************************************************************
    ///********************************************************************************************
    console.debug(measureTool + ", In GetAreaAndDistances...");
    require(["esri/geometry/geometryEngine", "esri/tasks/ProjectParameters", "esri/SpatialReference"],
        function (GeometryEngine, ProjectParameters, SpatialReference) {
            if (evtObj.geometry === undefined) { return; }
            try {
                var geometry = GeometryEngine.simplify(evtObj.geometry);
                var params = new ProjectParameters();
                params.geometries = [geometry];
                params.outSR = new SpatialReference(2855);//(102100);//(102748);
                params.transformForward = false;//true;//false;
                params.transformation = { wkid: 1515 };
                esriConfig.defaults.geometryService.project(params);
            } catch (exp) {
                //        alert("Invalid Geometry... ");
                console.debug("Invalid Geometry in GetAreaAndDistances..." + exp.Description);
            }
        });
}
function getProjectedArea(evtObj) {
    console.debug(measureTool + ", In getProjectedArea...");
    require(["esri/geometry/geometryEngine", "esri/tasks/AreasAndLengthsParameters"],
        function (GeometryEngine, AreasAndLengthsParameters) {
            if (evtObj.geometries[0] === undefined) { return; }
            try {
                var areasAndLengthParams = new AreasAndLengthsParameters();
                var areaUnit = getUnits(area_units);
                var distUnit = getUnits(dist_units);
                //setup the parameters for the areas and lengths operation
                areasAndLengthParams.lengthUnit = distUnit;
                areasAndLengthParams.areaUnit = areaUnit;
                areasAndLengthParams.calculationType = "geodesic";
                areasAndLengthParams.polygons = [evtObj.geometries[0]];
                esriConfig.defaults.geometryService.areasAndLengths(areasAndLengthParams);
            } catch (exp) {
                //        alert("Invalid Geometry... ");
                console.debug("Invalid Geometry in GetAreaAndDistances..." + exp.Description);
            }
        });
}


Outcomes