Create Polygon from Points
We have a create point activity, what would be the that equivalent to create a polygon. I have a bunch of points that I would like to turn into a polygon. Any help appreciated.
-
It's similar, but a little more involved. Since you can create a point. To create a line you just need two or more points. Creating a polygon is a series four or more points where the first and last point are identical.
-1 -
require([ "esri/geometry/Polygon", ... ], function(Polygon, ... ) { var polygonJson = {"rings":[[[-122.63,45.52],[-122.57,45.53],[-122.52,45.50],[-122.49,45.48], [-122.64,45.49],[-122.63,45.52],[-122.63,45.52]]],"spatialReference":{"wkid":4326 }}; var polygon = new Polygon(polygonJson); ... });0 -
Probably better example:
var singleRingPolygon = new Polygon([[50, 0], [150, 20], [150, -20], [50,0]]);0 -
Hi Tom, appreciate the help. How would i integrate the above into workflow? Would I use the create value activity?
0 -
I guess it would depend on how I received the points. The simplest would be to create the multi-dimension array, the above example, and make sure that the beginning and ending value were identical. Then create the Polygon using the new Polyg([your md array])
0 -
Hi Aaron.
I think you could use Create Value followed by Get Geometry From JSON.
So, for example, if we used the 2D Polygon example from Esri's Geometry objects page, we would set the Expression input of the Create Value activity to be:
= { "rings" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832], [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749], [-97.06326,32.759]]], "spatialReference" : {"wkid" : 4326} }Then, we would set the the JSON input of the Get Geometry From JSON activity to be:
=$value1.result(assuming the default id of Create Value is used)
0 -
Hi Ken,
what I ended up doing was using create value to create an array, then created a point, converted to json, used the add item activity to add them to the array
Next step to create the polygon was to use the create value activity with this expression
='{"rings": [['+$pointcollection.result+']],"spatialReference": {"wkid":4326}}'
then get geometry, then create polyon feature
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
7 kommentarer