Select to view content in your preferred language

Calculate column from two different layers as "1" and "Null"

1064
2
Jump to solution
03-03-2023 07:03 AM
Labels (3)
DeepSeaMapping
Emerging Contributor

I have a layer with point data (70K)  with an empty column XY and a layer with lines/roads (700)

In the empty column XY I want a “1” if a point is in distances of 10m of a road and if the point is not in a 10m Buffer of the road I want "NULL.

I do not know how to conditionally fill the empty column in regard to another layer.

Can anybody help me? Any ideas?

attached is a super simple sketch to visualise my problem

 

Thank you!

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

First, calculate all values of the XY column to null if they're not that already. Right click on the Points layer and select Joins and Relates and Add Spatial Join. Select the roads layer as your Join Features, Match Option of "Within a distance" and set the search radius. Click OK and your points table will now have a few more fields in it. Select the records that have a Join_count greater than zero, then use the Calculate Field option in the XY column to set these records to 1

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

First, calculate all values of the XY column to null if they're not that already. Right click on the Points layer and select Joins and Relates and Add Spatial Join. Select the roads layer as your Join Features, Match Option of "Within a distance" and set the search radius. Click OK and your points table will now have a few more fields in it. Select the records that have a Join_count greater than zero, then use the Calculate Field option in the XY column to set these records to 1

JohannesLindner
MVP Alum

You could use the Calculate Field tool.

Switch language to Arcade, use this expression (edit the 2nd line to load your line feature class)

// load the line feature class
var lines = FeaturesetByName($datastore, "LineFC")
// create a buffer aroun d the current point
var p_buffer = Buffer($feature, 10, "meters")
// get all lines intersecting that buffer
var i_lines = Intersects(p_buffer, lines)
// check the count and return the correct result
var c = Count(i_lines)
return IIf(c > 0, "1", "NULL")

 


Have a great day!
Johannes