Select to view content in your preferred language

Convert A Single FeatureSet Row To A Text String

77
1
yesterday
Labels (2)
GregReinecke
Occasional Contributor

Yesterday I learned how to create an Array, sort that array and keep the seconf record from it.  Today I wanted to try it using a featureSet as it allowed my to sort on a single numeric field.  My successful code is below:

// create 50mi buffer on selection
var buff = Buffer($feature,50,'mile')

// get intersecting staff locations
var staff = Intersects(FeatureSetByName($map, "InventoryIntersects"),buff)

// create empty featureset to hold results
var New_FS = {fields:[        
        {'name':'Development_Name','type': 'esriFieldTypeString'},
        {'name':'Project_Address','type': 'esriFieldTypeString'},
        {'name':'Project_City','type': 'esriFieldTypeString'},
        {'name':'Project_State','type': 'esriFieldTypeString'},
        {'name':'Zip_Code','type': 'esriFieldTypeDouble'},
        {'name':'Distance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
 
for (var s in staff){
    var dist = DistanceGeodetic(s,$feature,'miles')
    var distNum = Round(Number(dist),2)
    var dName = s.Development_Name
    var dAddress = s.Project_Address
    var dCity = s.Project_City
    var dState = "TX"
    var zipcode = s.Zip_Code
    var new_f = {'attributes': {'Distance': distNum, 'Zip_Code': zipcode, 'Development_Name': dName, 'Project_Address': dAddress, 'Project_City': dCity, 'Project_State': dState}
                 }
    Push(New_FS.features, new_f)}

var sorted = Top(OrderBy(FeatureSet(Text(New_FS)), 'Distance ASC'),2)
var topTwo = sorted
var filtered = Filter(topTwo, 'Distance > 0')
return filtered

which results in:


results.png

Is there a way I could simply convert this to a text string so I could use it in a popup like below?

" The location is at Padre De Vida Apartments - 3900 S Ware Rd,  McAllen  TX 78503 - 1.14 miles"

Thanks so much.

GRMapper

0 Kudos
1 Reply
namenbo
New Member

I read the data into a data frame df. It has only one column, with several rows. All rows are filled with texts, which are comments from a survey question. I googled for possible ways and went with .astype because I thought it would work.