2

I am trying to use an Arcade expression with GeoJSON services in a map using the ArcGIS Javascript API. The intent of the Arcade expression is to return a count of lakes that intersect a county that the user clicks on. Both the lakes and county polygons being GeoJSON services. Swapping out the lakes GeoJSON service with a ArcGIS Feature Layer service results in the expression functioning properly, returning the count of lakes that intersect the county GeoJSON service.

  var template = {
  title: "{LABEL}",
  content: "{expression/countyInfo}",
  expressionInfos: [
  {
    name: "countyInfo",
    title: "Marker Info",
    expression: `

    var lake = FeatureSetByName($map, 'Lakes');

    var lakeIntersect = Intersects(lake, $feature);

    var cnt = Count(lakeIntersect);

    return \` 
    Number of lakes: \${Text(cnt, "####")}   
    \`
    `
  }
  ]
};

I've tried changing the $map global variable in the FeatureSetByName function to the other global variables options ($datastore, $feature, $layer) but have had no luck.

Has anyone had any success creating a FeatureSet from a GeoJSON service, how did you declare it?

EDIT

Code can be found here

3
  • 1
    Can you provide a reproducible example of your code when loading this layer? What do you mean by GeoJSON services? GeoJSON is a file format, not a web service standard.
    – Dror Bogin
    Nov 10, 2020 at 5:00
  • @DrorBogin GeoJSON is a standard, not a file format. You can have GeoJSON files, you can have web services that return GeoJSON. They're all "GeoJSON" if they conform to the standard
    – user2856
    Nov 10, 2020 at 8:16
  • @DrorBogin yes, a link to the code has been added to the post. Nov 10, 2020 at 15:10

1 Answer 1

0

You can now solve this problem with a function in arcade called Intersects(). Despite your source layers being from a GEOJSON, they are layers referenced in the map. You can use FeatureSet functions as input parameters to the Intersect to identify intersecting Lakes in the County. For example:

Count(Intersects(FeatureSetByName($map,'Lakes', ['*'], true), FeatureSetByName($map,'County', ['*'], true)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.