AddField should be able to add a shape field to a table

336
1
08-13-2014 02:22 AM
Status: Open
Labels (1)
KimOllivier
Occasional Contributor III

I have a table that I want to make into a featureclass by adding a shape field and then populating the values.
This is not supported so I looked for alternatives. They are all very clumsy.

It comes about because I have a many to many relation so a simple join will not do. I want the first point from one featureclass to populate many rows in the table so that I end up with a featureclass with some coincident points.

Suggestion 1: In CreateFeatureClass() there is a <template> option. This will do.... oh no it won't! Why not? We already have to define a shape type and the spatial reference template at the end of the options is required for the spatial reference.  So why cannot we just use a table as a template without a shape field?

Suggestion 2: Simply allow AddField to add a shape field with suitable spatial reference. Then I don't have to painfully copy the table row by row into a dummy featureclass using a Python cursor. This is tricky to set up a field list, strip off the objectid field carefully and loop about.

Suggestion 3: Just use FME and abandon ArcGIS. Because this is available as a workaround nothing will change I fear.

Once I have the ( null) shape field it would be easy to populate it from a dictionary of XY values obtained from another featureclass.

Another complex workaround which could handle a many to one would be to use a Querylayer but both tables have to be in the same geodatabase so that would be another copy of another table.

I am ending up with a slow complex Python script that could be a simple one-liner.

1 Comment
KimOllivier
I have found a workaround at 10.3 - use a spatlalite database where you can do precisely this. Add a shape column to an existing table. Apparently every other GIS in the world already works like this!