Select to view content in your preferred language

Populate Endpoints of Line With a Field Value from Nearby Feature Class

303
4
Jump to solution
01-29-2025 12:51 PM
AKRRMapGuy
Regular Contributor

We have a network of lines that we need to assign 2 values from the closest points in a point Feature Class.

The line segments need the values from the closest points to the beginning and end of the line assigned to their respective field in the line FC. They are Mileposts, and we need to get the Milepost value in the 'MpFrom' and 'MPTo' fields in the Line. The lines are not always drawn in a low to high orientation.

My hang up is I can't find a an arcpy tool or Arcade function that selects the point closest to the line endpoint(s).

Does this functionality really not exist? Arcade would make it easy to bring the value across from the point to the line if I could just select it based on spatial relationship to the endpoint.

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Notable Contributor

Well as long as you get the correct marker values into 2 fields irrespective of them being mixed up/wrong way around, and assuming that the 'to' will be the highest value marker, then it shouldn't be that hard to sort out.

I'd create 2 additional final fields and field calculate the highest and lowest values into those respective fields.

The answer is pretty recent here:

https://community.esri.com/t5/arcgis-pro-questions/how-do-i-add-a-field-for-the-predominant-geologic...

for the 'final' from field (lowest).  Ensure you past the following into the 'Code Block' at the bottom of the Field Calculator window.

 

 

 

def minValue(*args):
    filtered = [arg for arg in args if arg is not None]
    return (min(filtered)) if filtered else None

 

 

 

then above the Code Block you will have something that looks like <fieldname being calculated> =
in the box below that enter (obviously replace with your fieldnames:

minValue(!yourField1!, !yourField2! )

 

For your final 'to' field (highest)

 

 

 

def maxValue(*args):
    filtered = [arg for arg in args if arg is not None]
    return (max(filtered)) if filtered else None

 

 

 

then above the Code Block you will have something that looks like <fieldname being calculated> =
in the box below that enter (obviously replace with your fieldnames:

maxValue(!yourField1!, !yourField2! )

View solution in original post

0 Kudos
4 Replies
DavidPike
MVP Notable Contributor

I think the simplest way to do it would be to create new points at the Start and End of your lines and then Spatial Join them over a few steps.

1. Feature Vertices to Points tool - specify 'START' option.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/feature-vertices-to-points.h...

2. Spatial Join to append the attributes of the nearest Milepost to the start.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/spatial-join.htm

3. Feature Vertices to Points tool - specify 'END' option.

4. Spatial Join to append the attributes of the nearest Milepost to the End.

5. Clean-up the final table and rename your fields as needed.

 

 

0 Kudos
AKRRMapGuy
Regular Contributor

It would take some fidgeting to get the end in the end column. Our lines aren't drawn in a way that goes from high to low necessarily. Some 'endpoints' should actually be the 'beginnings' and visa versa. I would have to set it so that whichever line is 'greater than' the other would be the 'to' I guess.

0 Kudos
DavidPike
MVP Notable Contributor

Well as long as you get the correct marker values into 2 fields irrespective of them being mixed up/wrong way around, and assuming that the 'to' will be the highest value marker, then it shouldn't be that hard to sort out.

I'd create 2 additional final fields and field calculate the highest and lowest values into those respective fields.

The answer is pretty recent here:

https://community.esri.com/t5/arcgis-pro-questions/how-do-i-add-a-field-for-the-predominant-geologic...

for the 'final' from field (lowest).  Ensure you past the following into the 'Code Block' at the bottom of the Field Calculator window.

 

 

 

def minValue(*args):
    filtered = [arg for arg in args if arg is not None]
    return (min(filtered)) if filtered else None

 

 

 

then above the Code Block you will have something that looks like <fieldname being calculated> =
in the box below that enter (obviously replace with your fieldnames:

minValue(!yourField1!, !yourField2! )

 

For your final 'to' field (highest)

 

 

 

def maxValue(*args):
    filtered = [arg for arg in args if arg is not None]
    return (max(filtered)) if filtered else None

 

 

 

then above the Code Block you will have something that looks like <fieldname being calculated> =
in the box below that enter (obviously replace with your fieldnames:

maxValue(!yourField1!, !yourField2! )

0 Kudos
AKRRMapGuy
Regular Contributor

And that was my missing piece. 4 fields to make 2. Thank you! I just needed that last little bit. 4 hours looking for a logical operation that doesn't exist didn't help me out lol.

All that said, I will say I am genuinely surprised endpoint spatial operators aren't really a thing in the ESRI ecosystem. Topologies and Geometry Calculations recognize them, but nothing else. That's wild to me in today's day and age. It would make these workflows so much more simple. 

0 Kudos