Select to view content in your preferred language

Distance between points along a polyline

21605
24
02-01-2015 05:36 AM
JodyCamille
Deactivated User

I have points marking tagged fish locations along a river. How do I measure the distance between each of those successive points?

0 Kudos
24 Replies
KirstenLawrence
Regular Contributor

Thanks for your reply that does make sense. I will test your code, thanks again.

0 Kudos
KirstenLawrence
Regular Contributor

I need to sort on more than just line id, oid and distance.. as I mentioned there are multiple sets of a points along each line that need to be grouped and then have the distance calculated.. essentially I think the dct key needs to include some additional fields

0 Kudos
DanPatterson_Retired
MVP Emeritus

Do you have a screen grab?  What sounded like a simple question now has more dimensions to it.

0 Kudos
KirstenLawrence
Regular Contributor

Here is a screenshot. The different colored points represent different vehicles that are traveling along the road. I have date/time values associated with each point, and the idea is to determine the avg speed of each vehicle by using the distance between each point in a given trip (which I am roughly determining by date and time), and then calculate the time difference between points to then determine the speed. I have over a million points!

0 Kudos
XanderBakker
Esri Esteemed Contributor

If you are willing to share a "small" part of the data we could have a look and see what method best matches your specific question.

0 Kudos
RichardFairhurst
MVP Honored Contributor

The lines dictionary won't change, since it only has the line ID.  The points dictionary can have any tuple for the key that you may want as long as the line ID is the first field in the tuple or at a known position in the key, so the look up of the line does not change.  I see no real difference in the way the code would be structured other than what values reset the counter.  So dct and dct2 would change but not valueDict.

In any case with over 1 million points and probably thousands of lines you would wait days or months for an embedded cursor to finish.  However, with that many points and lines you may run out of memory if you process the complete set into these dictionaries in one run.  You have to create a loop surrounding my code and process queries in the outer loop to segment the line and point sets into smaller groups (say iterating through ranges of 500 line IDs in the lines and points) .  The dictionaries would be cleared and reset in each loop so that your memory would not run out.

0 Kudos
GavinJackson3
Occasional Contributor

Richard

sorry to drag out an old thread and script, but I'm having issues using the script you provided with this solution.

its coming up with an error saying that the tuple has no attribute queryPointAndDistance.

I read the desktop help which indicates that your code should work, given an input point geometry and line.

Help Please!

Gavin Jackson

0 Kudos
RichardFairhurst
MVP Honored Contributor

As my post said, I never really tested that code.  However, I see which line of code needs to change to avoid the error you are getting.  I embedded the polyline geometry within a tuple in the dictionary value, so I need to use a tuple index so that the geometry will be assigned to the polyline variable and not a tuple with the geometry inside of it.  Line 25 of my code needs to change from:

            polyline = valueDict[line]‍

to:

            polyline = valueDict[line][0]
GavinJackson3
Occasional Contributor

Excellent thanks Richard. I did note that you had not tested it as yet and I was trying to work out the error myself, just got a bit out of my depth! I will test and report back.

0 Kudos
GavinJackson3
Occasional Contributor

and I'm back, we have success!. for the 60,000 roads in the network im running this on it takes 4 minutes to do the entire network - many thanks Richard you have been a massive help!