Select to view content in your preferred language

Arcade: Add a function that quickly converts a Featureset into an Array

1317
4
04-15-2023 05:00 AM
Status: Open
JohannesLindner
MVP Frequent Contributor

Please add a function that quickly converts a Featureset into an Array.

 

As discussed in this thread, it's sometimes necessary to convert a Featureset into an Array, but loading the Featureset takes a long time, especially accessing it for the first time.

 

So instead of this:

 

var fs = FeaturesetByPortalItem(Portal("https://arcgis.com"), "2b93b06dc0dc4e809d3c8db5cb96ba69", 0)
var fs_arr = []
for(var f in fs) {
    Push(fs_arr, Dictionary(Text(f)))
}
return fs_arr

 

 

It would be helpful (and hopefully much faster) to have a function like this:

 

var fs = FeaturesetByPortalItem(Portal("https://arcgis.com"), "2b93b06dc0dc4e809d3c8db5cb96ba69", 0)
var fs_arr = FeaturesetToArray(fs)
return fs_arr

 

Tags (1)
4 Comments
jcarlson

Please let me upvote this twice. This is desperately needed, and doesn't seem like something that would be that difficult to do, given that a FeatureSet's features object actually is an array.

Vinzafy

Full support for this idea! Being able to store feature sets as an array stored in local RAM as opposed to constantly pinging the server with requests is incredibly valuable in common workflows (e.g., joining tables programmatically).

This is not only beneficial for users, but also reduced significant burden on servers as a single script that previously sent hundreds to thousands of requests on the server now only sends one for each initial FeatureSet call.

And like @jcarlson mentioned, features objects are already arrays!

GregoryWhitaker

Upvote. Landed here searching for any which way to do exactly this. Related, a way to decode the feature set (and work directly with the object) like json dumps/loads would be nice too. 

PeterMilenkovic

This would be heaps helpful