Select to view content in your preferred language

SpatialJoin in Quickcapture

259
4
Jump to solution
09-11-2024 07:52 AM
AlbertoFlores
New Contributor

Hi!

I'm trying to make a quickcapture project in which upon capturing a point, a field of the point is populated depending on the spatial location. The way I thought of doing this is like a SpatialJoin, i.e. intersecting the polygon layer which contains the different areas with the point I just took and retrieving the value of that polygon.

For this I used some code in Arcade I found in this post, example 4. It worked fine but the thing is my field of work is forestry, which means a lot of field work with no reception whatsoever.

That isnt a problem to the code itself but I want to see an offline map while working and the only way I found of doing this is via mobile map package as a map in the quickcapture project. As far as I have tried, I cant use that code while a mmpk is the map of the project, it only works with a web map (which I cant use offline in quickcapture).

I kept thinking a workaround and I tried to use $datastore instead of $map, having the point layer and the polygon layer in the same feature layer so I can use a mmpk as a map. But, the following error popped and I cant find a solution: Cannot read properties of undefined (reading 'find')

So I ask you, is there a way to use an offline map while making an spatial join of the point captured and the polygon the point is taken in? I could use a solution to the aforementioned error or an entire different way to do it. 

Thanks!

This is the working code for a web map:

// Create a feature set using the 'prueba_int' layer in the map
var regions = FeatureSetByName($map, "prueba_int", ["SupA"]);

// Intersect the current location with the regions and
// get the first region
var region = First(Intersects($feature, regions));

// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
if (!IsEmpty(region)) {
  return region["SupA"];
} else {
  return null;
}

 

0 Kudos
1 Solution

Accepted Solutions
JohnathanHasthorpe
Esri Regular Contributor

Hi Alberto,

Yes you can use a MMPK as your project map and use Arcade to access an online feature layer using FeatureSetByPortalItem.

For example:

var facilities = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  "8cf16523599849fa8aa9a93c4c3122f1",
  0,
  ["name"],
  true
);

As the Arcade expressions will only run when features are uploaded (when the device is back online), it does not matter is the user is working offline when capturing data.

View solution in original post

4 Replies
JohnathanHasthorpe
Esri Regular Contributor

Hi Alberto,

Yes you can use a MMPK as your project map and use Arcade to access an online feature layer using FeatureSetByPortalItem.

For example:

var facilities = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  "8cf16523599849fa8aa9a93c4c3122f1",
  0,
  ["name"],
  true
);

As the Arcade expressions will only run when features are uploaded (when the device is back online), it does not matter is the user is working offline when capturing data.

AlbertoFlores
New Contributor

It worked fine, thanks!!!

 

Im still curious about the $datastore, how does it work exactly? I thought it was for features inside the same feature layer.

0 Kudos
FrankHerbert
Occasional Contributor

@AlbertoFlores  Did you find a way to pass the attribute from the intersect to the QuickCapture layer in an offline scenario? I have a similar problem - we don't have internet connection whilst capturing data.

0 Kudos
JohnathanHasthorpe
Esri Regular Contributor

The Arcade expressions in QuickCapture will run just before a feature is sent. For a feature to be sent the device needs to be online, so this is not a limitation.

Essentially, you can capture all your data offline. Get back to your office, open project (and online web map) and send your features to ArcGIS. The Arcade expression will run for each of your captured records prior to upload.

 

 

 

0 Kudos