In my road centerline features I'm trying to calculate the neighborhood names in the left and right sides of each road segment based on the neighborhood. To indicate which side to check, I'm including an Offset function to calculate the neighborhood name that intersects 1-foot on either side of the line. I'm also performing this in a file geodatabase. Here is my script:
var fsNbrhd = FeatureSetByName($datastore, 'Neighborhood', ['Nbrhd_Comm'], true)
var RoadLeft = Offset($feature, -1, 'us-feet', 'square')
var fsNbrhdLeft = Intersects(fsNbrhd, RoadLeft)
var NbrhdLeft = First(fsNbrhdLeft)
if (IsEmpty(Geometry(NbrhdLeft))) return
else if(NbrhdLeft == null) return null
else return NbrhdLeft.Nbrhd_Comm
I keep getting an error on line 4, "Search geometry cannot be null". However, if I change the variable on line 3 to the line itself instead of the offset:
var fsNbrhdLeft = Intersects(fsNbrhd, $feature)
I don't get the error, and it just calculates whatever polygon my line intersects. I think the problem might be with the Offset function.
I also tried adding error messages in the script to help identify the problem:
var fsNbrhd = FeatureSetByName($datastore, 'Neighborhood', ['Nbrhd_Comm'], true)
if (IsEmpty(Geometry(fsNbrhd))) return "error0"
var RoadLeft = Offset($feature, -1, 'us-feet', 'square')
if (IsEmpty(Geometry(RoadLeft))) return "error1"
var fsNbrhdLeft = Intersects(fsNbrhd, RoadLeft)
if (IsEmpty(Geometry(fsNbrhdLeft))) return "error2"
var NbrhdLeft = First(fsNbrhdLeft)
if (IsEmpty(Geometry(NbrhdLeft))) return "error3"
if(NbrhdLeft == null) return null
return NbrhdLeft.Nbrhd_Comm
When running this, all of the features returned "error0", indicating null geometry in my Neighborhood layer, but it seems to be drawing on the map with no problem, and it calculates fine if I ignore the offset and just calculate whatever intersects the line.
Has anyone else experienced this, or can help identify the problem?
Thanks,