Hi,
I need to calculate the geometry of a point feature based on the coordinates in the X and Y fields in the attribute table.
In the case below, I am replacing the existing Geometry. The configuration in the Field Calculator to do this looks like this:
Once I apply this, the existing point disappears from the map where I'd expect it to display in a new location based on the X and Y coordinates.
What am I doing wrong here?
Appreciate your assistance.
Albertus - couldn't you use the XY Table to Point (Data Management) GP tool instead to create a new feature class based upon the Point_X and Point_Y fields instead of recalculating the Shape field? Would that work better?
Hi Robert,
This is a Point feature class so not able to use the table to point tool. The idea here is that I add this arcade script in a Attribute rule in the geodatabase, where features will be inserted and upon insert, the point geometry is to be calculated.
Hope that explains it.
Hi @Alber_Verster ,
Can you elaborate a little more on the idea of using this in an attribute rule? An attribute will be triggered by a defined event. Does this event take place in the featureclass where you want to update the geometry or does this take place inside a different featureclass? If the latter is true it will require a whole different expression.
Some examples can be found here:
Hi Albert
I don't think you could replace the existing geometry field but might try to create a query layer instead.
Regards,
Bing
I've just had a play with Arcade and I too could not achieve the updating of the Shape field; may be it's not possible or if it is, it is not well documented as I could not find anything on the Help file.
That said it is completely achievable with python, this worked:
The code block is:
def replacepoint(x,y):
sr = arcpy.SpatialReference(27700)
point = arcpy.Point(x,y)
pg = arcpy.PointGeometry(point,sr)
return pg
Hi @DuncanHornby and @Alber_Verster
A field calculation is something different from an Calculation Attribute Rule. It is definitely possible to update a geometry using a Calculation Attribute Rule as described here: https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/attribute-rule-script-expression.h...
Yeah, I was testing the arcade expression using the field calculator before I setup the Attribute Rule in the EGDB on the point feature class.
Eventually I got it to working although I had to create a new point feature class table with the projection set as WGS84 (WKID 4326).
var new_point = {
"x": $feature.longitude,
"y": $feature.latitude,
"z": 0,
"spatialReference": { "wkid": 4326}};
Geometry(new_point)
With decimal degrees populating into the Latitude and Longitude fields, upon the record's insert into the table, the geometry is calculated and the point displays in the correct location.
For some reason this does not work for projected points in a Transverse Mercator type feature class and I have not found out why that is.