Dynamic and/or calculated field in ArcGIS Enterprise geodatabase?

2039
5
12-14-2020 10:53 AM
VincentLaunstorfer
Occasional Contributor III

Hi,

In a geodatabase, stored in ArcGIS Enterprise, is it possible to create dynamic and/or calculated field?

For a point feature, I'd like to create a LAT and LONG fields to store the decimal degrees of the location of the point, which will automatically (dynamically) update whenever the point geometry is changed/moved.. Somehow, it would be similar to certain fields maintained by the geodatase such as AREA and/or LEN.

Is it possible? This would be great.

Also, in practice, it would behave like a custom Arcade expression to display dynamic (calculated) fields in Pop-Ups, but actually stored in the geodatabase... 

0 Kudos
5 Replies
JoeBorgione
MVP Emeritus

Also, in practice, it would behave like a custom Arcade expression to display dynamic (calculated) fields in Pop-Ups, but actually stored in the geodatabase... 

What you are describing is an attribute rule, and you should be able to create one that does what you want...

See this post: https://community.esri.com/t5/developers-questions/how-can-i-get-x-y-in-dec-degrees-from-a-poly-feat...

That should just about do it....
VincentLaunstorfer
Occasional Contributor III

Hi Joe,

Thanks, it is a good start and an interesting thread on Arcade...

I need to dive into attribute rules for geodatabase as this is something I never done before.

And I found the ESRI docs: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-attribute-ru...

It should not be too difficult... Hopefully

0 Kudos
JoeBorgione
MVP Emeritus

It should not be too difficult... Hopefully

You'll need to get familiar with Arcade; start with some basic concepts with rules and ramp up to more complex. I started out exactly opposite to that: In my first exposure to Attribute Rules, I tried to figure out some very complex rules within an ESRI Solution, and nearly lost my mind.  (These days I'm wondering if there is anything left to lose...)

This forum is especially helpful so don't be timid; post your questions as you encounter issues.  I'm bringing @XanderBakker into this: without his advice and help I wouldn't be able to spell Attribute Rules or Arcade.

Attribute Rules are very useful; I especially like using them in concert with Geodatabase Sequences.  One caveat with using attribute rules is once they are deployed on a feature class, that feature class is unavailable to ArcMap users and/or users of ArcGIS Pro 2.0 and earlier.

That should just about do it....
VinceAngelo
Esri Esteemed Contributor

You could generate a view or SQL query using Query Layers which includes ST_X and ST_Y function calls (the usage for which varies by RDBMS implementation). Since "LONG" is reserved in some databases, I recommend using "LON" to pair with "LAT".

 

-- PostgreSQL geometry/geography
CREATE VIEW mypoints_w_coords AS
  SELECT objectid,colA,colB,ST_Y(shape) as lat,ST_X(shape) as lon,shape
  FROM   mypoints;

-- ORACLE SDE.ST_GEOMETRY
CREATE VIEW mypoints_w_coords AS
  SELECT objectid,colA,colB,SDE.ST_Y(shape) as lat,SDE.ST_X(shape) as lon,shape
  FROM   mypoints;

-- SQL Server geometry/geography
CREATE VIEW mypoints_w_coords AS
  SELECT objectid,colA,colB,shape.STY as lat,shape.STX as lon,shape
  FROM   [myschema].mypoints;

Note that some elements of geodatabase functionality aren't available with views, so processing the geometry in the client as with Arcade is probably a better solution.

 

VincentLaunstorfer
Occasional Contributor III

Thanks all to your contributions.

Vince's suggestion is also good but depending on the underlying DBMS, ST_Geometry can be limited. For lat/long, no problem with any DBMS. However, if trying to calculate geodesic length or area, ST_Geometry can be rubbish... at least with Oracle. Also, you need to create views.

On the other hand, attribute rules can be more powerful but need the underlying ESRI geodatabase environment...

As I already experienced ST_Geometry, I will investigate attribute rule and look how far I can go.