4

Is there a way for ArcGIS Desktop to populate a field automatically when a new point is dropped on the map?

We have our map in State Plane Feet, and we want to the database to automatically add WGS XY coordinates to fields in the table when a new point is added.

Something like a calculated field, but always there?

5
  • For reference, QGIS has a plugin that does these automatic calculations. It's called AutoFields. Besides geometric properties (area, perimeter, x coordinate, etc.), you can also set custom expressions (e.g., Field1 + Field2, Area/10000, etc.). – Germán Carrillo Sep 20 '16 at 2:55
  • 1
    Do you have any ArcObjects experience? There is an event OnSketchFinished in the IEditEvents resources.arcgis.com/en/help/arcobjects-net/componenthelp/… which parses the modified or new feature to the routine whenever a feature is added or modified. If you're not into C++, C# or VB.net there is a range of python options desktop.arcgis.com/en/arcmap/latest/analyze/python-addins/… onChangeFeature(self) onCreateFeature(self) but the onChangeFeature also traps attribute change and might be responding too often – Michael Stimson Aug 3 '20 at 3:08
  • @MichaelStimson, having looked at the answers, I think your comment is much closer to what OP asks. – fatih_dur Aug 5 '20 at 6:12
  • 1
    I would be concerned @fatih_dur that an answer based on the comment would be considered out of scope of the question as the OP does not mention any coding ability. If masterofnone would like to edit the question indicating if they are capable of understanding code answers I'd be happy to go back through my source and find an example of OnSketchFinished being implemented; I distinctly remember which tool but it was probably 7 years ago now so I'd have to dig deep. – Michael Stimson Aug 5 '20 at 6:17
  • Fair enough @MichaelStimson. Given on-the-fly calculation/update is not possible without an event trigger, I suggested the coding path. That's why people are paying developers for such out of the box functionalities. – fatih_dur Aug 5 '20 at 6:25
4

I'm not aware of out-of-the-box functionality within ArcMap that dynamically adds X/Y coordinate fields when you add a point. However, you can use the tool Add XY Coordinates both manually and programatically (Python) if you want. For example, you could create an automated task to run Add XY Coordinates on the layer(s) you want on a daily/weekly/monthly basis that will add/update the XY fields.

2
  • So there is no trigger like functionality to features? – masterofnone Aug 22 '12 at 20:58
  • They only one I'm aware of is that you can select an attribute while actively digitizing that is symbolized uniquely and it will add that attribute to your new features. E.g., a Name field that has Smith and Jones symbolized differently in the layer. You can choose Smith or Jones and it will auto-populate that field in the next feature you digitize. – Baltok Sep 5 '12 at 18:06
2
+100

You can use "Label Feature" as a trigger. So use this Python label expression:

SR = arcpy.SpatialReference(4326)
lyr = "points"
with arcpy.da.UpdateCursor(lyr,("Shape@","WGSX","WGSy")) as cursor:
 for shp,fx,fy in cursor:
  newP = shp.projectAs (SR).firstPoint
  cursor.updateRow((shp,newP.X,newP.Y))
def FindLabel ( ):
  return None

Just modify second line or simply call your layer "points". Also amend X and Y field names in line 3.

I tested it on 500 long dataset and noticed no delay in features redraw with "Label Feature" option ticked. You can even attach this expression to dummy layer with single feature, like shown in picture below:

enter image description here

It's enough to switch this dummy layer on, to trigger calculations on target layer. However script honors selection so either attach it to target, or clear selection on it, when using slave. Use layer properties, to access labeling dialog.

1
  • Using "Label Features" option of right click menu is an action trigger is quite clever! Knowledge of the day! – fatih_dur Aug 5 '20 at 6:15
1

Baltok's option is probably what you are looking for, but you can also use XTools to populate all your records with XY. The tool is called Add XY Coordinates and its a free tool within XTools.

1
  • 1
    It is likely that @Baltok was referring to the Add XY Coordinates Tool that is part of the core package, so you do not need to add an extension to do it. – Get Spatial Aug 22 '12 at 16:16
1

This is an old question, but thought I would provide an possible answer. If you are using ArcSDE (e.g. with MS SQL Server, Oracle, or PostGIS), you can set up a database trigger to automatically populate the values in x and y fields whenever a new record is added (inserted) or edited. There is an example on this post here for case of MS SQL Server: Populate X and Y fields in SDE Point Data Using SQL trigger Although note that the example would only trigger when a new record is inserted. I would recommend also triggering when records are updated, so that if you say need to shift a point it will recalculate the coordinates.

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.