Select to view content in your preferred language

Calculating Centroids using Attribute Rules

1387
2
Jump to solution
10-17-2023 08:26 AM
Labels (1)
Peter_Green
New Contributor III

Hello and thank you for your time.

I'm running ArcGIS Pro 3.1 on Windows 10.

I'm attempting to use Attribute Rules to populate selected fields within a feature class each time a new feature is created. These are the steps I've taken: 

- I've created a new feature layer and added separate fields to hold X and Y coordinates of new features. For testing purposes, I've tried various data types for these fields, including Long, Float, Double. I've also tested with points, lines and polygons.

- In Attribute Rules I've created a separate rules for the X and Y fields. The rules are intended to populate the X and Y coordinate fields using the Centroid($feature) function with the x or y centroid of the feature. See the attached image (Attribute_Rule.jpg) for the rule set-up.

When a new feature is created in the feature layer the rule appears to run successfully (i.e. no error messages), however the X and Y fields are populated with "0"s and not the actual coordinate. This happens regardless of the projection, feature class type or feature data type.

Here is what I've tried.

- I've run this with feature classes/maps in both WGS84 and BNG.

- I've tried different data types (long, double, float).

- I've tried different feature class types (point, line and poly).

- I've also tried calculating the X and Y coordinates using the "Calculate Geometry" tool. When this is run, I receive various warning messages, such as "WARNING 160096: The length of the value exceeds that of the field." See attached for full list of warnings. The process still completes and the fields are calculated with the correct centroid coordinates. 

- It's worth mentioning that I've also created a separate Attribute Rule to calculate the length or area of lines and polygons. This rule works fine and correctly calculates the values. 

Not sure what else to try here. I've noted that others have reported similar issues on other posts dating back to v2.7 (circa 2021) but there didn't seem to be a resolution at the time. 

Thanks for reading. Please let me know if you have any suggestions.

Thanks,

Peter

 

 

1 Solution

Accepted Solutions
AyanPalit
Esri Regular Contributor
2 Replies
AyanPalit
Esri Regular Contributor

@Peter_Green try the process posted here: https://community.esri.com/t5/arcgis-pro-questions/automatic-centroid-point-calculation/m-p/1333373 

Ayan Palit | Principal Consultant Esri
Peter_Green
New Contributor III

Thank you very much, Ayan. 😀 That did the trick. Looks as though my expression was not as complete as I'd thought it was. Regards.

0 Kudos