I have points marking tagged fish locations along a river. How do I measure the distance between each of those successive points?
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
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!
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.
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.
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]
polyline = valueDict[line]
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.
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!