1

I have several sample locations, that have been sampled several times at the same location. I want to label each location with stacked data from each location. So it would hopefully look like this

"Sample Location 1:

Depth 0-6: .314

Depth 6-12: .315

Depth 12-48: .398"

And so on. The problem right now, is that if I try and label them with label expressions, I can stack the fields but not the rows. So I get 5 labels for each location. This is because the depth measurements have their own points. I need the unique values so I cannot dissolve/aggregate the points into mean values, so that eliminates a lot of tools.

I also cannot simply display the different readings in labels located around the point. Because there are so many points, and I need to label all of them, the only way I can think of to label all of them at once is to combine them into single labels for each point and THEN do Maplex operations to get all the labels displayed properly.

I have explored python expressions and I am having a hard time finding something close to what I am doing. This StackOverFlow question has been suggested for me to attempt but it has not worked for me: Can labels for overlapping points be combined/merged into one label?

When I try the "Update #2" code in that solution it simply says "No Features Found: Could not Verify Expression". I am also not sure that's what I am even looking for because I do not want the sample data averaged or aggregated; I want the unique sample data displayed for each point.

In terms of label expression, I think of pseudocode like this:

def FindLabel ( [SAMPLE], [DEPTH], [READING]): 
     print [SAMPLEID]
     for [DEPTH] within [SAMPLEID]:
        return [DEPTH],  [GLNPO_TOTA], [FIELDS_TOT]

Where hopefully it would be possible to have ArcGIS display a sample location, then the depths and values below it, all as one label. That's the idea at least.

5
  • 2
    I think the second half of this answer to the duplicate indicated on your earlier question does the hard part of what you seem to be trying to do. What happened when you tried it? Formatting the text is easy, the hard part is aggregating the points and their data to make the labelling easy.
    – PolyGeo
    Sep 30, 2015 at 21:12
  • I cannot aggregate the data because the unique values have to be maintained. In that example answer I don;t understand what "MUID" would correspond to in my attribute table. I tried substituting the sample location, and the sample IDs, and that didn't work. Whether it is MUID or sample locations in both cases it says "No features Found"
    – cakebug
    Sep 30, 2015 at 21:23
  • You would aggregate only for labelling purposes and still maintain your original data. I've not tried the solution but if this was my question I would edit it to say something like "when I did these exact steps to try the solution suggested at ... this is precisely what happened on a simple test case of 3 points at the same location".
    – PolyGeo
    Sep 30, 2015 at 21:29
  • But I don't want to aggregate for labeling purposes either. I need unique values listed for each point and labelled. I can't average the depths of each location because I want to label and show the values at each depth. Unless I am not understanding what you mean by aggregating points.
    – cakebug
    Sep 30, 2015 at 21:34
  • Aggregating in this case means adding extra fields and using a cursor to transfer values. If three points have a field with one value, and you know three is the maximum number of points at a location, use three fields to store the three values on one point.
    – PolyGeo
    Sep 30, 2015 at 21:38

1 Answer 1

1

Look at my code in this blog post for how to connect a single point to a separate table or feature class to list all of the related data stored in multiple records/points. You want to dissolve your points based on a location ID to create a separate point feature class that contains just a single point for each physical location (you won't be using any aggregated fields created by the dissolve, just the location ID). This avoids having to deal with label duplication and greatly improves the speed of labeling. The single point feature class must have a field with a unique ID for each point that is also contained in all of the overlapping points at that location. Then the code can list all of the overlapping point data in a single label using a cursor and a dictionary.

The key to the code I have designed is the use of a global dictionary variable in the label expression that is populated for all points once by a cursor when the first label is being created. The actual labels do not read the data directly from the cursor, they just use the dictionary, which is at least 10 times faster than running separate queries for each point. The dictionary key is the Unique ID for each unique physical point location and the value associated with each dictionary key contains a list of all the related data you need from the separate points for each given location. Once you are set up to read field data from the lists in the dictionary, the rest of the label code is all about formatting the output.

14
  • having some trouble getting this working, here's what I've tried: 1: I dissolved based on the locations and did them as singlepart. So the dissolve table only has the sample location in it. 2: Then I related that dissolve table to the original table, based on the sampleID. 3: I then changed the code from the blog so it is pointing to my dissolve table for the relate, the labelkey is the sample ID, but for "relatefield list" I only put SampleID. If I try to put other fields it says column not found. 4: Line 49 in example 1 isn't working for me; it says Tuple out of range when run (cont.)
    – cakebug
    Oct 1, 2015 at 17:18
  • "expression += '\n{} - {:.4f}'.format(fieldValues[1], fieldValues[0]) " causes "Tuple out of range". I tried changing it to the field names of the columns I want to display (so it is expression += '\n' + [DEPTH] + [TOTAL] on line 49) but that causes issue where it says "findlabel not defined". Am I supposed to include the fields I want displayed in label in the relate table?
    – cakebug
    Oct 1, 2015 at 17:21
  • I'm marking what you said as answered because even though I'm having issues getting this working for me it's clear that with some tweaks this is what I needed
    – cakebug
    Oct 1, 2015 at 17:32
  • The code in example 1 should be modified in 4 lines. Line 3 should be modified to def FindLabel ( [SAMPLEID] ): Line 9 should change to your related points/table path (it must contain the SAMPLEID, DEPTH, and TOTAL fields). Line 12 should be changes to: relateFieldsList = ["SAMPLEID", "DEPTH", "TOTAL"] Line 34 should change to: labelKey = [SAMPLEID] Line 49 should not be changed if you made these 4 other changes. Oct 1, 2015 at 18:48
  • In sample 1 you would also want to make the label text fit your data better by changing the string from "Cross Street Count = " in line 43 and line 53 to "Sample Count = ". Oct 1, 2015 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.