Create point geometry in a feature class with all the attributes prepopulated

805
2
Jump to solution
04-17-2013 10:04 AM
AlexeyTereshenkov
Regular Contributor III
So here is the problem. I have a text file with space delimited values. A standard text file with the headings separated by spaces and then on each next line values for these headings (columns) also separated with spaces. Each row represents a certain geographic point feature; however no coordinates (XY-pair) are stored in this text file.

My ultimate goal is to view each row in ArcMap individually (like one can do with the attribute table in ArcMap), edit the attribute values (if needed) and specify the point geometry of the feature by clicking on a map. And here is my issue ??? it seems as I cannot create a feature class without SHAPE field, but because I don???t have any coordinates in the source text file I cannot populate SHAPE field upon creating a new feature class.

What is the most efficient way of achieving this? I am a bit puzzled due to the workflow when all the attributes are populated yet the geometry is to be created. Ideally the solution would be to let user see the attribute table (obtained from the text file), then user selects a certain row user wants to work with, she digitizes a point on the map and the SHAPE field is populated with this point geometry. I understand that this is not how ArcMap was designed, but how one can come closest to this without investing too much in writing an advanced add-in or using ArcObjects?

I have considered so far:


  • creating a feature class from this text file with some random coordinates, but it is not an applicable alternative because to edit a point feature a user would need to zoom to this point and then move it to another geographic area (using the ArcMap editing session). Since the geographic extent of the points in this collection might be quite large, it would be nearly impossible to use this approach.

  • creating a geodatabase table from the text file and then let user click on the map to digitize a map point which would represent a certain row in the table (however creating a point feature in a separate feature class). Thereafter, user can choose to transfer all the attributes of a geodatabase table row to the newly created feature (was thinking of using arcpy.da.UpdateCursor here or running a Python script with the join table & feature class > export logic). However, this would imply that when user digitizes a point feature, he would need to enter a custom ID that would match the ID of the row in the table. Right now it seems as there is no maintained unique ID heading in the text file and since multiple text files can be received independently, this approach looks also pretty cumbersome.

Any other suggestions folks?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Frequent Contributor
I am pretty sure in 10.1 you can create a python add-in that can accept x,y mouse clicks as an input. You should be able to reference the highlighted row of a table to get the values and insert those attributes into a point feature class along with the x,y input from the mouse. How to specifically go about doing this I'm not sure, I haven't made any tools with that kind of functionality.

View solution in original post

0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
I am pretty sure in 10.1 you can create a python add-in that can accept x,y mouse clicks as an input. You should be able to reference the highlighted row of a table to get the values and insert those attributes into a point feature class along with the x,y input from the mouse. How to specifically go about doing this I'm not sure, I haven't made any tools with that kind of functionality.
0 Kudos
AlexeyTereshenkov
Regular Contributor III
I am pretty sure in 10.1 you can create a python add-in that can accept x,y mouse clicks as an input. You should be able to reference the highlighted row of a table to get the values and insert those attributes into a point feature class along with the x,y input from the mouse. How to specifically go about doing this I'm not sure, I haven't made any tools with that kind of functionality.


Thanks Mathew, that was what I've ended up developing 🙂
Some simple logic behind it:

1. User selects a feature in the attribute table of the feature class created from the text file (here inserting null geometries or just 0,0 for coordinates would work fine).

2. User chooses what location this feature will have by double-clicking this location on the map. This fires up several things.

2a. The add-in's onMouseDownMap(self, x, y, button, shift) function gets XY coordinates of where the user clicks (in fact, only the first click of the mouse is required here).

2b. The add-in's onDblClick(self) function starts running. The logic checks with the Get Count GP tool if there is exactly one feature selected. Here is the arcpy.da.UpdateCursor comes into play. I am updating the geometry of the selected feature based on the XY values received earlier in another function.

Lastly, refreshing active view.

The Python add-ins turned out to be powerful and easy to develop, highly recommended. The add-in works fine and does what it needs to get done.
0 Kudos