Is there a way to get nearest distance from a point to a specific field within an attribute table?

1295
10
06-27-2023 11:34 AM
Labels (2)
Hailey215
New Contributor II

Hi all! Hopefully I am able to word this in a way that makes sense..

I have a shapefile with points, and one with roads, and I am trying to figure out how to get the nearest distance from the points to a specific type of road within the roads shapefile. The roads attribute table has a "Surface" column, and I'd like to get distance from each point to the nearest paved road, then nearest unsurfaced road, and so on.

My plan was to "Select By Attributes" for each road type, then export them to their own shapefiles, so I could do a simple "Spatial Join", but the roads shapefile will not allow me to "Export Features".

Is there a different way to do this? Any and all help/advice would be greatly appreciated!

 

0 Kudos
10 Replies
TonyContreras_Frisco_TX
Occasional Contributor III

I have not tried this, but I think either the Generate Near Table  or the Near tools would find the closest feature. If you use the Near tool, it will modify the input features' schema (point feature class). If you are ok with that, the good part is that you can join the point features to their closest road feature segment to get access to the surface attribute. The same can be done with the Near table output, but there would be more steps. There might be other tools that are more direct, and if there are I hope someone shares that here. If not, at least you have something to try.

Robert_LeClair
Esri Notable Contributor

I'd recommend reviewing the Near (Analysis) geoprocessing tool to see if this will accomplish what you're looking to do.  You could do a select on paved roads first, then dirt and so.

Hailey215
New Contributor II

Thanks y'all for the tips! I looked at the Near tools, and unless I'm missing something, I don't think this will work. I can select my points layer as my "Input Features", and my roads layer as the "Near Features", but I believe this will just tell me what the nearest road is. There doesn't appear to be anywhere I can select a specific field or attribute within the roads layer to be my "Near Features". If that makes sense?

0 Kudos
Hailey215
New Contributor II

@TonyContreras_Frisco_TX I'm fairly certain I understand what you are saying. I know that I can use the "Near" tools to tell me what the nearest road to each point is in general. And that by combining attribute tables, I can then see what the surface type is for the nearest road. But what I'd like to see is not just the nearest road, but the nearest paved road, or unpaved road, or gravel road, etc. And all of those road types are combined within the roads layer. But I could just be misunderstanding what the output will be, so I am planning to run it today and just see what happens.

0 Kudos
TonyContreras_Frisco_TX
Occasional Contributor III

I understand now. I missed the requirement you noted to do that for each road type. In that case, you should be able to select or apply a definition query for a value (as others have said), run the tool, export the point feature class, specifying the road type in the file name, then repeat for each road type. That is with the Near tool. using the Generate Near Table tool is a little messier, but does not alter the schema of the point feature class. 

0 Kudos
TonyContreras_Frisco_TX
Occasional Contributor III

In my response above, I mention that there is another part to this process, which is joining the two tables/feature classes together, using the result of either of the tools. Once you do that, your point feature class will have access to the value of the surface (or any) attribute of the road layer feature that was identified as the closest to that point.

0 Kudos
Jordan_Brasher
Esri Contributor

Hi, @Hailey215. When you say that you are unable to export features from the roads shapefile, can you explain a little more about what's happening? Are we able to select the ones we want, right click on the layer > Data > Export? Is the export option greyed out or something? Alternatively, does it run and not finish? What is happening there? 

0 Kudos
Hailey215
New Contributor II

I am able to do select by attributes, and select all of a single road surface type within the roads layer, but yes, when I try to export, the "Export Features" option is greyed out. And it's possible I'm just not understanding what the output of the "Near" tools is, but I will be running it today just to see what happens. I thought that by running it, I would get the distance from each point to just the nearest road in general, not to a specific road type I wanted.
My other thought was this, if I select by attributes in the roads layer, and highlight all of one road type, then I do a spatial join between the point layer and roads layer, will the join happen between the points and ONLY the selected attributes of the roads layer?

0 Kudos
Jordan_Brasher
Esri Contributor

@Hailey215 yes, when you do the spatial join while one of the input layers has a selection, it should only run the tool on the selected features. To verify this before running it, check to see if there's a message under the input layer in blue text that says X number of features are selected.