Select to view content in your preferred language

Create a list with a data expression that creates a buffer of an existing feature

1327
3
Jump to solution
06-19-2024 11:22 AM
Labels (1)
GIS_utahDEM
Frequent Contributor

Hello! I am trying to create a data expression to populate a list in dashboards that reflects all the features of an existing featureset, but with a specific buffer around them. Mainly, I'm just not sure where in feature's attributes I can access/change the geometry and I'm having a hard time finding documentation about it. I currently have it on line 27 in the code below -- but I'm honestly not sure if that is where it would go OR if that would be the correct key to use.

 

var agol = portal('https://www.arcgis.com')
var layer = FeatureSetByPortalItem(agol,'0ca544f09ff94130b2685fbcbb7f89f1');

var recalc = {
  'fields': [{'name':'Name', 'type':'esriFieldTypeString'},
  {'name':'objectid','type':'esriFieldTypeOID'},
  {'name':'globalid','type':'esriFieldTypeGlobalID'},
  {'name':'Type','type':'esriFieldTypeString'},
  {'name':'Status','type':'esriFieldTypeString'},
  {'name':'Date','type':'esriFieldTypeDate'},
 // {'name':'search_date','type':'esriFieldTypeDate'}
  ],
  'geometryType': '',
  'features': []
}


for (var a in layer) {
  var new_a = {'attributes':{
    'Name':a.Name,
    'objectid':a.OBJECTID,
    'globalid':a.GLOBALID,
    'Type':a.Type,
    'Status':a.Status,
    'Date':a.Date,
  },
  geometry:Buffer(Geometry(a),50,'miles')
  }
    Push(recalc.features, new_a)
}

return FeatureSet(Text(recalc))

 

When I "Run" it, I get a table with the appropriate attributes, but no shape field
0 Kudos
1 Solution

Accepted Solutions
GIS_utahDEM
Frequent Contributor

Well -- I solved my own problem and it actually does work for filtering and such on the map...but I'll keep it here in case someone else wants to see how I did it!

View solution in original post

0 Kudos
3 Replies
GIS_utahDEM
Frequent Contributor

Well -- I solved my own problem and it actually does work for filtering and such on the map...but I'll keep it here in case someone else wants to see how I did it!

0 Kudos
HollyTorpey_LSA
Frequent Contributor

@GIS_utahDEM Do you still have the code that ended up working? I'd love to see it.

- Holly
0 Kudos
GIS_utahDEM
Frequent Contributor

The data expression ended up taking a really long time and frequently failed, so instead I have a hosted notebook that runs on a schedule to just create/update a separate buffer layer that has been added to the map and dashboard. You can see the code I used for the buffer creation here: 

 

https://github.com/julia-surkis/SituationalAwareness/blob/main/IncidentPointsToBuffer.ipynb

0 Kudos