Select to view content in your preferred language

Intersects() error - Search Geometry cannot be null

1501
5
06-02-2022 06:20 PM
by Anonymous User
Not applicable

Hello all,

I'm getting an unusual error while trying to use the Intersects() function on an attribute rule in our Enterprise Geodatabase (10.9.1).

For a bit of background, the company I work for has a database of point features that represent the location of Cultural heritage items. When a new site is appended, we need to check if the site ID is a duplicate, and if the site being entered is in the same location as an existing site. 

The duplicate site ID check using a filter is working fine, but I am getting the error "Arcade error: search geometry cannot be null, script line 9" when I try to save the attribute rule. 

I have checked the input feature class for points with Null geometry and removed a few stragglers, I've also tried swapping out the FeaturesSetByName for another fc in our database, but I'm still getting the same error. 

I've also tried guarding against nulls by nesting the count of intersects in an IIf statement that checks for an empty result when the existing_ahims_sites variable is called. 

Any help would be greatly appreciated. 

 

// reference the sites database
var existing_ahims_sites = FeatureSetByName($datastore, "gdb.owner.fd_nsw_ch_cultural_heritage_site_point", ['niche_id']);
var new_ahims_id = $feature.niche_id;

//check for intersects
var intersect_count = 0
intersect_count = Count(Intersects(existing_ahims_sites, $feature))

//set the intersect result to a default value
var intersection_result = "Intersection check was not conducted"
//query the output of the intersect check and update the result variable
IIf (intersect_count > 1, intersection_result = "Site intersects existing point", intersection_result = "Site does not intersect existing point") 

//check for duplicate site IDs
var duplicate_check = filter(existing_ahims_sites, "niche_id = @new_ahims_id")
//guard against null results
var duplicate_count = 0
var duplicate_count = Count(duplicate_check)
//set the duplicate ID result to a default value
var id_check = "ID check was not conducted";
//query the output of the duplicate check and update the result variable
IIf (duplicate_count > 1, id_check = "Site id already in database.", id_check = "site ID not found in database") 

//combine the results
var site_validation_result = Concatenate([id_check, intersection_result], '; ')
return site_validation_result

 

5 Replies
JohannesLindner
MVP Frequent Contributor

It's hard to tell what the error could be, because there is no code in line 9 in your code. Please try the code below and post the error message if you get one.

Things I noticed:

  • You're using IIf() wrong. The signature is IIf(condition, value_if_true, value_if_false).
  • Apparently, you're manually entering IDs for the site, which leads to the need for checking for duplicates. You should consider using a database sequence and assigning the ID automatically with NextSequenceValue().
  • For this problem, you don't need to guard against null values. A) because if Intersects() or Filter() don't find any entries, they will return an empty feature set with a Count() of 0. B) because you will find at least 1 feature (the current $feature) with both Intersects() and Filter().
    • At least, you don't need the cjecks you tried to implement. Your error suggests that there is an empty geometry somewhere (probably the Intersects()), could be that you have to guard against that.
    • You do need to guard against null when you do something like this:
      First(empty_featureset).Attribute 
      Calling First() on an empty featureset returns null, and trying to call an attribute of null will result in an error.

 

// reference the sites database
var existing_ahims_sites = FeatureSetByName($datastore, "gdb.owner.fd_nsw_ch_cultural_heritage_site_point", ["niche_id"])
var new_ahims_id = $feature.niche_id

//check for intersects
var intersect_count = Count(Intersects(existing_ahims_sites, $feature))

//query the output of the intersect check and set the result variable
var intersection_result = IIf(intersect_count > 1, "Site intersects existing point", "Site does not intersect existing point")

//check for duplicate site IDs
var duplicate_count = Count(Filter(existing_ahims_sites, "niche_id = @new_ahims_id"))

//query the output of the duplicate check and set the result variable
var id_check = IIf(duplicate_count > 1, "Site id already in database.", "site ID not found in database")

//combine the results
var site_validation_result = Concatenate([id_check, intersection_result], "; ")
return site_validation_result

 


Have a great day!
Johannes
0 Kudos
HaochunGuo123
New Contributor

Hello,

Have you found a solution to this issue? I got the same error! 

Cheers,

Haochun

0 Kudos
JohannesLindner
MVP Frequent Contributor

Hey,

can you please post more info?

  • What Arcade profile are you working in (Popup, Attribute Rule, Dashboard, etc)?
  • your code
    JohannesLindner_0-1661842403744.png
    JohannesLindner_1-1661842429872.png
  • the error message (with line number)

Have a great day!
Johannes
0 Kudos
JonathanPollack
Frequent Contributor

I am getting the same error when trying to run an expression in a Calculate Field.  It errors out when trying to evaluate the "IIf (intersect_count > 1," giving the null geometry error.  The only way around this was to do a "Select by Location" of all points that intersect with my polys, then run the calculate field but it is very slow....

I could also use "ADD SPATIAL JOIN" for this but it is also very slow...

0 Kudos
JohannesLindner
MVP Frequent Contributor

Just checked, this error occurs when you try to do an Intersects() with null geometries.

Check your feature classes for empty geometries, for example with this Arcade expression in Calculate Field:

return IIf(Geometry($feature) == null, "NULL GEOMETRY", null)

Have a great day!
Johannes
0 Kudos