Select to view content in your preferred language

Address Data Management Solution; Calculate left and right field "Search geometry cannot be null"

180
1
08-19-2024 09:45 AM
zmontom23
New Contributor

I am working on calculating left and right fields from a line that has been offset by 5 meters and intersects an underlying polygon. Despite trying various Arcade expressions, I consistently encounter the following error: ERROR 002712: Search geometry cannot be null.

Recently, I adapted a code snippet from GitHub, converting the line feature to a point feature on line 11. I validated the expression beforehand and its shows as a valid expression.  However, I still receive the same error on line 14 when I click on apply, which indicates that the geometry cannot be null. Could you provide any insights into why this issue persists? 

// This rule will populate the edited features field with a value from an intersecting feature

// Value to copy from the intersected feature
var intersecting_field = "BEAT";
//Field rule is assigned to in the Attribute Rule
var feature_field = "leftbeat";

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'Beats', [intersecting_field], true);

var intersecting_point =centroid(offset(buffer($feature,1,'meters'),-5,'meters'));

// Intersect the edited feature with the feature set and retrieve the first feature
var intersected_feature = First(Intersects(intersecting_featset, intersecting_point));

// Check to make sure there was an intersected feature, if not, return the original value
if (intersected_feature == null)
{
return $feature[feature_field];
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature.BEAT))
{
return $feature[feature_field];
}
// Return the intersected features value
return intersected_feature[intersecting_field];

 

I have managed to get this code to perform the intended calculations, but there are errors in the results. Specifically, it calculates the left field for all features except for 149, and it calculates the right field for only 149 out of 109,000 features. There are no queries involved, and the 149 features not calculated in the left field are not related to the ones calculated in the right field. 

var beat = featureSetByName($datastore,'Beats',['BEAT'],true);
var leftbeat = '';
//This converts the current feature (line) to a polygon, offsets the polygon 5 meters and then converts the polygon to a point. 
var lbpoint =centroid(offset(buffer($feature,1,'meters'),5,'meters')); 

for ( var f in beat ) {
  if ( intersects( lbpoint,geometry(f) ) ) {
       var leftbeat = f.beat
       break;
   }
}

return leftbeat

 

0 Kudos
1 Reply
TedHoward2
Esri Contributor

You're on the right track with using Offset but you shouldn't buffer it beforehand. I think that's what's causing the error.

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'Beats', [intersecting_field], true);

// Offset polyline to left and right
var left_line = Offset($feature,-5,'meters')
var right_line = Offset($feature,5,'meters')
// Find midpoints of newlines
var left_point = DistanceToCoordinate(left_line, Length(left_line)/2).coordinate
var right_point = DistanceToCoordinate(right_line, Length(right_line)/2).coordinate

// Intersect the edited feature with the feature set and retrieve the first feature
var intersected_left = First(Intersects(intersecting_featset, left_point));
var intersected_right = First(Intersects(intersecting_featset, right_point));