Label duplicated points with the maximum value of one of them.

317
2
05-24-2022 07:57 AM
VaL
by
New Contributor III

Hi,

I got a case where I have 3 points with the same coordinates (duplicated, but need to be). Each has an attribute (numeric) with different values:

e.g

point,value

1,55

1,44

1,456

2,33

2,34

2,67

3,45

3,65

 

What I want to to label these points on the map, but only showing the highest value for each of them. So only one label for point 1 showing 456 etc.

Any ideas how to do so?

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Unfortunately, you really won't be able to do this with the built-in labelling tools. The labelling profile of Arcade does not have access to the various FeatureSetBy... functions. In other words, the label of an individual feature cannot "see" the values of other features in the same layer.

You could get closer to this idea with a text marker in the layer's symbology, but you'd need some way of overriding the feature drawing order with an attribute, which is currently not possible in Pro.

- Josh Carlson
Kendall County GIS
0 Kudos
JohannesLindner
MVP Frequent Contributor

Doing this on the original data is going to be hard or impossible.

The two possibilities I see:

Use SQL

Create a Query Layer or Database View. In a very basic form:

SELECT PointName, Max(Value) AS "MaxValue"
FROM Featureclass
GROUP BY PointName

 

Use Attribute Rules

Create a new point feature class. Needs a value field.

On your original point feature class, create an Attribute Rule that edits the newly created fc, something like this (untested):

// Calculation Attribute Rule on original point fc
// field: empty
// triggers: insert, update, delete

// load the label point fc
var labels = FeatureSetByName($datastore, "LabelPoints", ["OBJECTID", "Value"], false)

// intersect the label fc with the active $feature
var label = First(Intersects(labels, $feature))

// create empty arrays to hold commands to add, update, or delete features in the label fc
var adds = []
var updates = []
var deletes = []

// if we're inserting or updating a point and there is no label point there, add it
if($editcontext.editType != "DELETE" && label == null) {
    var new_label = {
        "geometry": Geometry($feature),
        "attributes": {"Value": $feature.Value}
    }
    Push(adds, new_label)
}

// if we're inserting or updating and there already is a label point there, update its value
if($editcontext.editType != "DELETE" && label != null) {
    var updated_label = {
        "objectID": label.OBJECTID,
        "attributes": {"Value": Max(label.Value, $feature.Value)}
    }
    Push(updates, updated_label)
}

// if we're deleting a point and there are no other points in that location, delete the label
if($editcontext.editType == "DELETE" && label != null) {
    // load the point fc
    var points = FeatureSetByName($datastore, "Points", ["OBJECTID"], false)
    // intersect with label
    var points_at_location = Intersects(label, points)
    if(Count(points) == 1) {  // only the current $feature, no other points
        var deleted_label = {"objectID": label.OBJECTID}
        Push(deletes, deleted_label)
    }
}

// return, this instructs the gdb to insert, update, or delete a feature in the label fc
return {
    "edit": [{
        "className": "LabelPoints",
        "adds": adds,
        "updates": updates,
        "deletes": deletes
    }]
}

 


Have a great day!
Johannes
0 Kudos