Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.13 KB

SpatialInheritance.md

File metadata and controls

29 lines (22 loc) · 1.13 KB

Spatial Inheritance (Fetch an attribute from an underlying polygon)

Sometimes, it can be valuable to store the geographic area a feature was collected in. In the past, this could be done manually by selecting the region from a list of values or by post processing the data. Now, this can be streamlined and automatically captured in the field by using a form calculation that performs a spatial intersection of the current location and a layer of polygons representing the geographic areas.

Example

I am recording bird sightings and want to automatically store the region I’m in.

// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null; }

// Create a feature set using the 'Regions' layer in the map, and
// intersect the current location with the regions.
var regions = Intersects($feature,FeatureSetByName($map, 'Regions', ['name']));
 
// get the first region
for (var r in regions){
    region = r;    
}

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