2

The end result of what I'm trying to do is convert a FGDB into a folder of shapefiles. To do this, I need access to all the data I'd expect to see in a shapefile. Once I get all the information I need from the file geodatabase, it should be really easy.

I am stuck on trying to read the file geodatabase spatial data (Xs and Ys)

UPDATE: Using the snippet of code posted by Rich Wawrzonek below, I can read the names of the datasets. Now I need to know how to read the Xs and Ys of each dataset!

    IEnumDataset enumDataset = iwrk.Datasets[esriDatasetType.esriDTFeatureClass];
    IDataset dataset;
    while ((dataset = enumDataset.Next()) != null)
    {
         //Do something with the feature class here
         Console.WriteLine(dataset.Name);
    }
  • Don't use \\ use a single \ in your file path. Also if the ArcObjects code is not working it could mean that it failed to initialize, you should check that worked first. – Hornbydd Aug 7 '14 at 17:59
  • Even when I use "@"C:\florida.gdb" instead, same result – Evan Parsons Aug 7 '14 at 17:59
1

It looks like you are using the older method of license check-out.

Try this:

   if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
      ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

UPDATE:

Based on your additional info it appears that you have a valid IWorkspace object. To access the contents you can use the IEnumDataset interface to iterate the datasets. Keep in mind that if there are Feature Datasets in your geodatabase then you also need to iterate through those to get to the nested datasets. Here is one way to set up a loop that searches for feature classes which are not in a feature dataset:

IEnumDataset enumDataset = iwrk.Datasets[esriDatasetType.esriDTFeatureClass];
            IDataset dataset;
            while ((dataset = enumDataset.Next()) != null)
            {
                //Do something with the feature class here

                Marshal.ReleaseComObject(dataset);
            }

This help page has lots of info on the arcobjects for gdbs: Geodatabase help doc

  • That cuts down on the amount of code that I had, but the end result is the same, the IWorkspace instance is empty. – Evan Parsons Aug 8 '14 at 12:08
  • What is the result? In your screenshot it looks like the IWorkspace obj is not null. workspaceFactory.OpenFromFile(path, 0) should throw an error if it can't open the gdb. Check some properties of the workspace obj that is returned, such as PathName, and you'll know if you're good to go. – Rich Wawrzonek Aug 8 '14 at 19:04
  • PathName is returned. Is there any examples I can look at for using the DataSets? – Evan Parsons Aug 11 '14 at 12:59
  • iwrk.DatasetNames[0] just returns System.__ComObject – Evan Parsons Aug 11 '14 at 13:15
  • I am able to output the names of the datasets with "Console.WriteLine(dataset.Name);"!!! That's great.Thank you. Now where is the spatial (X's and Y's) in each dataset? – Evan Parsons Aug 13 '14 at 13:03

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.