Solved! Go to Solution.
I got the code to work just fine. It calculated 15 in the MMONOTONIC field. Seems like I do not have monotonicity. How can I correct this? Simplify the line?
I switched RID to 1 and re-generated the Event Table (attached).
I zoomed into points 13 and 14 and there doesn't appear to be any complex curving here.
Hi,
I am attempting to measure the distance between sites (points; n=50) that were sampled along a trail using the Linear Referencing tools. I created a "route" from my trail feature class (line; dissolved into one single feature) and was able to run the Locate Features Along Route tool without any errors. I then ran Make Route Event Layer so that I could view my points after they had been "snapped" to the trail, which all looked great.
The problem I am having is with the values in the Measure Field, which is supposed to list the distance at which each point exists along the trail. I sorted the Measure Field in descending order and expected that my sites would then be listed in the order in which they appear along the trail, and this is the case for the first 12 sites. However, the 13th site listed is the one at the opposite end of the trail and then the remaining sites are listed in sequential order and meet back up with the 12th site. I checked to see if this could be explained due to the values being measured from the other end of the trail, but this didn't add up.
So basically, it seems that the Measure Field was not calculated properly. I would greatly appreciated any insight into this. Many thanks in advance!
def MMonotonicity(feat): partnum = 0 # Count the number of points in the current multipart feature partcount = feat.partCount pntcount = 0 mmonotonicity = 0 lastM = -100000000 # Enter while loop for each part in the feature (if a singlepart feature # this will occur only once) # while partnum < partcount: part = feat.getPart(partnum) pnt = part.next() # Enter while loop for each vertex # while pnt: pntcount += 1 if lastM < pnt.M and lastM != -100000000: mmonotonicity = mmonotonicity | 1 if lastM == pnt.M and lastM != -100000000: mmonotonicity = mmonotonicity | 2 if lastM > pnt.M and lastM != -100000000: mmonotonicity = mmonotonicity | 4 if not pnt.M: mmonotonicity = mmonotonicity | 8 lastM = pnt.M pnt = part.next() # If pnt is null, either the part is finished or there is an # interior ring # if not pnt: pnt = part.next() partnum += 1 return mmonotonicity
Sort by RID and then by measure and be sure all of the events have the same RID values. The RID field includes zeros for each record. Maybe this is a clue to the problem?
Thank you for the code. I do have some Python experience. However, I am not sure how I would implement/modify this code for my situation. Can this be used in the Python window in ArcMap or would it require IDLE (or other)? Would I reference my data by defining a variable named "feat" which points to my point feature class?
Is your actual Route ID for your trail 0?
Right click the MMONOTONIC field I told you to add to the Routes and choose the Calculate Field. Then input the calculation. Each step is listed from top to bottom of the field calculator tool and there are 4 things you need to set. No modification of the code is needed. It just ensures that there are no hdden problems in your routes and become more important when you start dealing with large datasets, such as the 30,000+ routes I deal with.
Yes, the Route ID of the trail is zero. So it seems that the RID field of the Events is populated appropriately.
I ran the code you provided using field calculator in a new "MMONOTONIC" field (long integer) and recieved error 999999 (attached). Maybe because I only have one route represented by one record?
The attached image also shows the section of the trail where the calculation jumps and the attribute table of the route layer. For reference, this distance between the 13th and 14th point is about 500 meters.
I got the code to work just fine. It calculated 15 in the MMONOTONIC field. Seems like I do not have monotonicity. How can I correct this? Simplify the line?
I switched RID to 1 and re-generated the Event Table (attached).
I zoomed into points 13 and 14 and there doesn't appear to be any complex curving here.