Count of point features existing within a certain distance from a line feature.

15259
12
Jump to solution
10-11-2015 01:45 PM
RaghunandanBaireddy1
New Contributor III

I want to obtain the count of point features existing within a certain distance from a line feature. I only need the count, the output table I would like to see should look something like shown in the table below. I have tried using the generate near table tool, but the output in that case will have to be manually simplified to meet my requirements. Can anyone suggest me an easier way to generate an output in the format I tried to describe?

FID
Line_Feature_IDCount of Point Features within the search distance
0123
128
2319
34526
4568
563
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor

This can all be done with a single tool, the Spatial Join tool.​  Use the JOIN_ONE_TO_ONE option, which will automatically create a count field for the join features. Set the lines as the target and the points as the join features.  Use the KEEP_ALL option to retain lines that have no points within the search tolerance, or the KEEP_COMMON option if you only want lines in the output that actually have points within the search radius. You can delete all fields from the Field map, since the tool will generate a TARGETID field in the output that retains the original line ObjectID value.  The INTERSECT match option should be fine.  Set the search radius to the distance around the line that you want (i.e., 100 feet).  The output will be a line feature class, which you can symbolize based on the Count. If you want just a table open the TableView and export it or select and copy the records into a spreadsheet if you just want a spreadsheet.  That should be it.

Here is a sample input.

And here is the output with the lines symbolized according to the point count.  You also retain the line length this way, which may be important for understanding the count:

For better performance you should buffer the lines by 100 feet first, which will retain the line ObjectID in a field the Spatial Join tool can use.  Then use the buffers instead of the original lines with the above settings (except use a search radius of 0), then add a count field to the lines and join the Buffer ID to the original line ID and calculate back the point counts.  You do not want to do a JOIN_ONE_TO_MANY and summarize, as that is a wasted step.

View solution in original post

12 Replies
DanPatterson_Retired
MVP Emeritus

you can generate the near in both directions, from points to line or reverse.  Also, what did you get as output?  Was that it?or the desired output.  It is not clear.

0 Kudos
RaghunandanBaireddy1
New Contributor III

I apologize for being ambiguous. Let me elaborate.

When I used the 'Generate Near Table' tool, I specified certain search distance and unchecked the 'Find closest feature only' option. So in the output table, I get the list of all points located within the search distance from each line, along with their ranks. For example if there are 10 points within a distance of 100 feet from a line (Whose FID is say, 15). I get 10 new rows (all related to this line with FID 15), in each row is the rank for every one of those 10 points.

Perhaps, this picture will explain what I am trying to say more effectively, This is how it is supposed to work right?Screenshot (14).png       

However, I only need the count of those points, not the ranks and the extra rows they bring along. I need a simplified table which says a line with so-and-so FID has these many number of points located within a distance of 100 feet from it. Now, how can I get something like this? The table I posted along with my question is meant to serve as an example of what I am trying to obtain, I made it in excel, it is no product of ArcMap.

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Hello Raghunandan,

You could try the following steps

1) Create a buffer using the line features with a specified linear distance.

Buffer—Help | ArcGIS for Desktop

2) Use spatial join to add the values of the buffer layer to the point layer. Join Operation parameter should be JOIN_ONE_TO_ONE (Edited). The output should be the point features containing the attributes of both the layers.

Spatial Join—Help | ArcGIS for Desktop

3) Open the attribute table of Spatial_Join layer. Right-click the Line_Field_ID (as per your example), SUMMARIZE.

Specify an output table, and click OK. The resulting table should display the desired output.



Think Location
RaghunandanBaireddy1
New Contributor III

Hey Jayanta,

Thanks for chipping in. Mr. Fairhurst has provided a more refined version of your solution, I have used that method to successfully finish my work. Anyways, I appreciate your help.

RichardFairhurst
MVP Honored Contributor

This can all be done with a single tool, the Spatial Join tool.​  Use the JOIN_ONE_TO_ONE option, which will automatically create a count field for the join features. Set the lines as the target and the points as the join features.  Use the KEEP_ALL option to retain lines that have no points within the search tolerance, or the KEEP_COMMON option if you only want lines in the output that actually have points within the search radius. You can delete all fields from the Field map, since the tool will generate a TARGETID field in the output that retains the original line ObjectID value.  The INTERSECT match option should be fine.  Set the search radius to the distance around the line that you want (i.e., 100 feet).  The output will be a line feature class, which you can symbolize based on the Count. If you want just a table open the TableView and export it or select and copy the records into a spreadsheet if you just want a spreadsheet.  That should be it.

Here is a sample input.

And here is the output with the lines symbolized according to the point count.  You also retain the line length this way, which may be important for understanding the count:

For better performance you should buffer the lines by 100 feet first, which will retain the line ObjectID in a field the Spatial Join tool can use.  Then use the buffers instead of the original lines with the above settings (except use a search radius of 0), then add a count field to the lines and join the Buffer ID to the original line ID and calculate back the point counts.  You do not want to do a JOIN_ONE_TO_MANY and summarize, as that is a wasted step.

RaghunandanBaireddy1
New Contributor III

Dear Mr. Fairhurst,

Thank you so much for providing an elegant and effective solution to my problem. I have to work on several different line shapefiles and your solution made my work much easier. Thank you so much sir!
 

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

There are a few ways you could accomplish this.  Here is on.  First, use the Multi Ring Buffer command to create you distances.  Make sure you specify the units.  For my test, I created three lines, but select one to run the sample against.

Next, run the Intersect tool with the Points and the Buffers as input. (the red X in mycase is I already ran it and would have to change the output name)

-

Then run the Frequency statistics to get a count on the distance field

Output table and sample graphic

Point count (frequency) within each buffer ring.  In this case 4 points within 10 km of my line, 7 between 10-20 Km of my line, etc. Is the Frequency table the output you are looking for?

RaghunandanBaireddy1
New Contributor III

Miss Strauch,

It worked, this is exactly what I am looking for! Thank you so much for taking such pains to explain the process to me. I really appreciate it ma'm. Here is a screen-shot, I have drawn a red box around the specific part of results I am interested in. Thanks again!

Screenshot (15).png

0 Kudos
RichardFairhurst
MVP Honored Contributor

Use Spatial Join.  It is the elegant solution to your problem.  Rebecca's solution may work, but it applies several unnecessary steps.  Try the Spatial Join and you will see that I am right..