How to change the Z Resolution of a feature dataset?

3493
2
Jump to solution
03-31-2015 01:31 PM
Highlighted
Occasional Contributor III

is there a way to change the Z Resolution of a feature dataset? I think that I can do this by creating a new feature dataset with the correct Z Resolution, and then load all of the data into new feature classes in the new feature datsaet. However, this database currently has a bunch of data in it, with multiple users editing data in multiple versions, which I'd like to preserve, so I'm looking for a way to simply re-define the Z Resolution. I'd even be OK with having to re-poplulate the Z values, as this wouldn't be too hard.

Thanks,

Jon.

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Occasional Contributor III

The problem was that the user that I was using to connect to the enterprise geodatabase was not the owner of the feature dataset. Once I connected to the enterprise geodatabase using the DBO user, then I was able to change the Z resolution.

An updated code sample which gets a schema lock on the feature dataset, and sets the Z resolution directly, is shown here:

            IGeoDataset geodataset = datasets.Next() as IGeoDataset;

          

            // retrieve and modify spatial reference

            ISpatialReferenceResolution spatialReferenceResolution = (ISpatialReferenceResolution)geodataset.SpatialReference;

            spatialReferenceResolution.set_ZResolution(false, 0.001);

            // acquire schema lock

            ISchemaLock schemaLock = (ISchemaLock)geodataset;

            schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

            // apply modified spatial reference

            IGeoDatasetSchemaEdit geoDatasetSchemaEdit = (IGeoDatasetSchemaEdit)geodataset;

            if (geoDatasetSchemaEdit.CanAlterSpatialReference)

            {

                geoDatasetSchemaEdit.AlterSpatialReference((ISpatialReference)spatialReferenceResolution);

            }

View solution in original post

2 Replies
Highlighted
Occasional Contributor III

I've created a code snippet that works for a file geodatabase, but not for the enterprise geodatabase with which I'm working:

            IGeoDataset geodataset = datasets.Next() as IGeoDataset;

            ISpatialReference spatialReference = geodataset.SpatialReference;

            spatialReference.SetZDomain(-1371.0, 29035.0);

            IGeoDatasetSchemaEdit geoDatasetSchemaEdit = (IGeoDatasetSchemaEdit)geodataset;

            if (geoDatasetSchemaEdit.CanAlterSpatialReference)

            {

                geoDatasetSchemaEdit.AlterSpatialReference(spatialReference);

            }

With a file geodatabase, changing the Z domain changes the Z resolution, which is the expected behaviour. However, when I try against the enterprise geodatabase, I get a COMException:

System.Runtime.InteropServices.COMException was unhandled

  HelpLink=esri_csGeoDatabase.hlp

  HResult=-2147216107

  Message=Layer not found

  Source=esriDataSourcesGDB.SdeWorkspace.1

  ErrorCode=-2147216107

  StackTrace:

       at ESRI.ArcGIS.Geodatabase.IGeoDatasetSchemaEdit.AlterSpatialReference(ISpatialReference SpatialReference)

       at EngineConsoleApplication3.Program.Main(String[] args) in c:\Users\Jonathan Bailey\Documents\Visual Studio 2012\Projects\EngineConsoleApplication3\Program.cs:line 36

       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException:

There aren't any connections to the enterprise geodatabase other than the one that I created in the ArcObjects code. Is there something else I need to do like compress the database? Delete all the versions(!)?

Thanks,

Jon.

Reply
0 Kudos
Highlighted
Occasional Contributor III

The problem was that the user that I was using to connect to the enterprise geodatabase was not the owner of the feature dataset. Once I connected to the enterprise geodatabase using the DBO user, then I was able to change the Z resolution.

An updated code sample which gets a schema lock on the feature dataset, and sets the Z resolution directly, is shown here:

            IGeoDataset geodataset = datasets.Next() as IGeoDataset;

          

            // retrieve and modify spatial reference

            ISpatialReferenceResolution spatialReferenceResolution = (ISpatialReferenceResolution)geodataset.SpatialReference;

            spatialReferenceResolution.set_ZResolution(false, 0.001);

            // acquire schema lock

            ISchemaLock schemaLock = (ISchemaLock)geodataset;

            schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

            // apply modified spatial reference

            IGeoDatasetSchemaEdit geoDatasetSchemaEdit = (IGeoDatasetSchemaEdit)geodataset;

            if (geoDatasetSchemaEdit.CanAlterSpatialReference)

            {

                geoDatasetSchemaEdit.AlterSpatialReference((ISpatialReference)spatialReferenceResolution);

            }

View solution in original post