I am using the sf package to create new spatial datasets, via the st_sf() function. I do not understand the use of the attribute-geometry relationship argument of this function. The help file specifies that it defines how each non-geometry field relates to the geometry field, and takes one of three values for each row: "constant", "aggregate", or "identity". There is also a value for unknown.

Here is what I can understand from the help file:

"constant" is used for attributes that are constant throughout the geometry (e.g. land use)

For a polygon or a line, this indicates that whatever the attribute is describing does not change inside the feature, such as (per the example) a homogeneous polygon of land use.

"aggregate" where the attribute is an aggregate value over the geometry (e.g. population density or population count)

From what I can tell from the example, this is used when the attribute is calculated from the geometry itself. Area and perimeter in the sf example are classified as 'aggregate' attributes.

"identity" when the attributes uniquely identifies the geometry of particular "thing", such as a building ID or a city name

And with respect to "identity", I cannot find a salient example of this being different from "constant".

To test this, I loaded demo(nc) and tried various combinations of agr values. Changing the values randomly had no impact on the class of the fields, their values, or how they behaved when summarized.

Can someone please explain why this argument exists, and how (or if) I should be using it when creating features?


"constant" means if you split the feature up, that attribute is still correct for both parts.

example: land use category. split a field in half, both halves are still fields.

"identity" is for attributes for features which when split, aren't the same any more. They've lost their identity.

example: the name attribute of a county. split it in half and each part is not the county any more. yes, each part was part of the county, but each one is no longer the county. If the original feature had the name "Foo County" then the splits would have to be "North Foo" and "South Foo" (or such) to be correct.

"aggregate" is for attributes which are partitioned across the feature in some way - such as population count. Attributes for aggregated features need some mathematical treatment when the features are split, typically dividing the attribute in proportion to the area of the split feature.

Notice that population density is a "constant" type, but population count is "aggregate" over polygons.

  • thank you for your answer. Do you consider agr a form of metadata? It seems like it gives directions to analysts rather than directly impacting the functionality of the data objects.
    – Matt
    May 13 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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