AnsweredAssumed Answered

Calculate geodesic area of polygon.

Question asked by KNShah on Jun 7, 2017
Latest reply on Jun 9, 2017 by KNShah

Hi,

I would like to calculate the area of polygon in ACRES. The polygon is created from JSON arrays and is in Geographic coordinate system. I would appreciate for any help or samples. Here is my sample work

 

require([

"esri/map",
"esri/layers/FeatureLayer",
"esri/geometry/Polygon", "dijit/form/Button",
"esri/graphic", "esri/geometry/geodesicUtils", "esri/units", "esri/SpatialReference",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol", "esri/Color", "esri/geometry/webMercatorUtils",
"esri/tasks/ProjectParameters",
"esri/graphic", "esri/tasks/FeatureSet", "dojo/dom-construct", "dojo/dom", "dojo/on",
"dojo/domReady!"
],
function(
Map,
FeatureLayer,
Polygon, Button, Graphic, geodesicUtils, Units, SpatialReference,
SimpleFillSymbol, SimpleLineSymbol, Color, webMercatorUtils, ProjectParameters,
Graphics, FeatureSet, domConstruct, dom, on, ready
) {

var map = new Map("map", {
basemap: "topo",
center: [ -96.878361, 34.186651],
zoom: 14
});


function showPolygon(){

var myPolygon = {"geometry":{"rings":[[
[-96.880511,34.209403], [-96.880378, 34.20944], [-96.880158, 34.209623], [-96.879584, 34.209696],
[-96.879319, 34.209787], [-96.879076, 34.209916], [-96.878702, 34.210263], [-96.878503, 34.210373],
[-96.878172,34.210464], [-96.877665, 34.210776], [-96.877267, 34.210922], [-96.877025, 34.21116],
[-96.877069, 34.211452], [-96.87718, 34.211543], [ -96.877356, 34.211562]]],
"spatialReference":{"wkid":4326}},
"symbol":{"color":[0,0,0,64],"outline":{"color":[0,0,0,255],
"width":1,"type":"esriSLS","style":"esriSLSSolid"},
"type":"esriSFS","style":"esriSFSSolid"}};


//var gra = new Graphic(myPolygon);


//map.graphics.add(gra);


}

function projectToWebMercator() {
var sr3 = new SpatialReference(102725);
var Geometries = [];
//var geomarray = arguments[0];
Geometries.push(esri.geometry.geographicToWebMercator(myPolygon));
var geom = esri.geometry.geodeiscAreas(Geometries, esri.Units.ACRES);

console.log(geom);

map.graphics.add(geom);
}


on(dom.byId("showPolygon"), "click", showPolygon);
on(dom.byId("convert"), "click", projectToWebMercator);


});

Outcomes