Arcade docs: Working with vertices

367
0
03-08-2022 11:08 PM
Status: Open
Labels (1)
Bud
by
Frequent Contributor


Could Esri add a section to the docs that explains how to work with vertices in Arcade?

For example, to loop through polyline vertices and read them, do the following:

var geo = Geometry($feature);
for (var part in geo.paths) {
    var line_part = geo.paths[part]
for (var i in line_part) {

 
To loop through polyline vertices and modify them, do the following:

var geo =  Dictionary(Text(Geometry($feature)));
var paths = geo['paths'];
for (var path_idx in paths){
    for (var vert_idx in paths[path_idx]){

Explanation:
Geometries are immutable, so we can't modify them directly. But if we convert them to a dictionary, then we can modify the entries in the dictionary, and then use that dictionary to create a new geometry.

 

As far as I know, there isn't anything in the docs that explains how to work with individual vertices by looping through geometries. Sure, there are samples in the GitHub repo, and they're definitely useful. But it seems like a thorough explanation in the docs would be a big help to people who are learning this stuff from scratch. 


Related post: Arcade: Get paths array from feature