Select to view content in your preferred language

Move feature classes out of feature dataset

7812
17
Jump to solution
11-27-2019 10:03 PM
OlovMelin
Occasional Contributor

hello!

I have an enterprise geodatabase with a number of feature datasets. Every feature dataset has a number of feature classes and relationship classes. The relationship classes are pointing to feature classes in the same feature dataset but also to feature classes in other feature dataset in the sama geodatabase.

The geodatabase is used by ArcGIS Server, FME and various scripts that we don't want to remake.

Is there a method or way to move all feature classes and relationship classes to the root of the geodatabase? I know that it doesn't matter for the arcgis server and FME if the feature class is in an feature dataset or the root, it will find it anyway. However, I have big time issues with moving/copying this relationship classes. If I simply use the method of copying data with new name -->delete old files and rename the new, the relationship classes will stop working.

Is this an dead end? Better to delete all reationship classes, move data and make new ones?

0 Kudos
1 Solution

Accepted Solutions
Asrujit_SenGupta
MVP Regular Contributor

You can try this:

1. Select all the Feature Classes and Relationship Classes inside a Feature dataset

2. Drag and drop them on the root, basically drag and drop on the sde connection file.

Note: Try on a backup first and not directly on Production.

View solution in original post

17 Replies
DanaNolan
Frequent Contributor

I think it is a dead end. You can create relationships with a geoprocessing tool, so that could save some typing and reduce errors if you use similar options and naming conventions for the parameters in the relationship. Just edit the Results of the tool for each feature, or build a little model.

Asrujit_SenGupta
MVP Regular Contributor

You can try this:

1. Select all the Feature Classes and Relationship Classes inside a Feature dataset

2. Drag and drop them on the root, basically drag and drop on the sde connection file.

Note: Try on a backup first and not directly on Production.

OlovMelin
Occasional Contributor

Hi, and thanks for your reply. This method only works if the relationship classes reference to featureclasses in the same feature dataset. Otherwise it will also copy and paste the other feature datasets automatically.

0 Kudos
Asrujit_SenGupta
MVP Regular Contributor

Not Copy/Paste. I suggested Drag and Drop.

OlovMelin
Occasional Contributor

Alright . I will try it right away!

OlovMelin
Occasional Contributor

That action worked. Many thanks

AngelaDeegan
Frequent Contributor

After doing what you describe, do you know the most efficient way to fix references in Pro maps to these feature classes?

In a development environment I successfully dragged/dropped feature classes & relationship classes out of a feature dataset. (My plan is to eventually delete this feature dataset.) However I have maps that use these feature classes and relationship classes in their layers. And I noticed that when I check the source of the layers, it still references the old feature dataset. These maps are published to our development Portal. And nothing seems to be broken in there. But I'm thinking these incorrect references will probably cause issues somewhere along the line. Do you know what is the best way to fix them?Pro map with layer source reflecting a feature dataset that the feature class is no longer in.


0 Kudos
Asrujit_SenGupta
MVP Regular Contributor

So, I tested on my end and I could reproduce the behavior.

The behavior is only observed for Feature Classes which are already added to Map, not otherwise. I am not sure if these will cause any issues, however it may cause confusion for sure, so its surely better to fix them if possible.

only solution I found:

Remove the affected FC from the Map Contents, refresh the connection and re-add the FC to the map. Now check the source, it doesn't refer to the Feature Dataset anymore.

Note: Always try on a backup first and not directly on Production.

AngelaDeegan
Frequent Contributor

Thank you very much for checking into this and letting me know your findings. I'm currently looking to see if there's a programmatic way to do this by leveraging getDefinition on Layer. So far I have only been able to display the feature dataset for layers in a map, but not change it. I think really what I need to be able to do is remove the featureDataset attribute for the layer.

def updateFDstToRoot(prj, mp):
    ##Script to display any FCs that still indicate they are in the 'gis.sde.WaterDistributionRelated' feature dataset - though all feature classes were moved (dragged/dropped) from it to 'root;

    import arcpy, sys

    aprx = arcpy.mp.ArcGISProject(r'C:\Users\angela\Documents\ArcGIS\Projects\DEVwork\{}.aprx'.format(prj))

    #Get list of all the maps in the project
    mps = aprx.listMaps()
    print(r"There are {} maps in project {}".format(len(mps), prj))
    #print(mps)
    mnames = []
    for m in mps:
        mnames.append(m.name)
    print(len(mnames))

    #Get the index of the map we want to work on
    map_pos = mnames.index(mp)
    print(r'{} is in position {}'.format(mp, map_pos))

    #Get a handle on the map
    m = mps[map_pos]
    print(m.name)

    lyrs = m.listLayers()
    print(len(lyrs))
    for l in lyrs:
        lCIM = l.getDefinition('V2')
        try:
            dc = lCIM.featureTable.dataConnection
        except Exception as Ex:
            print('******Failed: {}\nLine: {}\n'.format(Ex, sys.exc_info()[-1].tb_lineno))
       else:
          if hasattr(dc, 'featureDataset'):
             if dc.featureDataset == 'gis.sde.WaterDistributionRelated':
                print("**** {} needs updating".format(l.name))
             else:
                print("{} DOES NOT NEED updating".format(l.name))
   #aprx.save()
   del aprx

updateFDstToRoot('DEVwork', r'EngineeringViewer-DevDB')
0 Kudos