List all features classes in a particular dataset

I could successfully loop through all feature classes in ESRI-geodatabase features. But, some of these features resides inside dataset. How can I list all feature classes in one particular dataset.
Thanks

Hello @alrajhi20

I’m not sure I fully understand your question. It might help to provide a little sample code, showing how you are trying to read the Feature Classses and Datasets.

As you may know, MapWinGIS uses the GDAL library for all non-Shapefile datasources. So it might also help to review the GDAL documentation regarding the ESRI GDB Driver.

Regards,
Jerry.

Hi Mr. Jerry,
I have a esri-geodatabase that has multiple datasets. All other feature classes are classified inside these datasets. See picture:
ds
Now for example, I just want to list all feature class in AeronauticalInformation dataset only. I am not interested in other datasets.
Well, your statement: “As you may know, MapWinGIS uses the GDAL library for all non-Shapefile datasources” is very helpful, so I will look at GDAL library to find out how.
Thanks

Hi Mr. Jerry,
I really could not find a clean and understandable code of GDAL library for my problem.
Would you please guide me with code or with link.
Thanks in advance

Are you able/allowed to upload the AeronauticalInformation dataset? I don’t know what the GDB looks like through through the API, but I could have a look and try some things.

Regards,
Jerry.

I don’t know what do you mean with “upload the AeronauticalInformation dataset”. but I have this gdb in my C# winforms application.
I would appreciate it if you could have a look to my sample esri geodatabase attached. Try to for example to list feature classes in Metadata dataset.
sample.zip (2.1 MB)

Thanks in advance

Hello @alrajhi20

I don’t see a Metadata dataset. What I see are 5 layers, being
index_100k, index_50k, Road, BuildUpArea, and Enclosure.

And each of the layers have a number of Features, as displayed below (zoomed in to the significant area).

Here is the code I used:

Dim ds As New OgrDatasource()
Dim cs As String = "c:\temp\sample\data.gdb"
If ds.Open(cs) Then
    Dim layers As Integer = ds.LayerCount
    For i = layers - 1 To 0 Step -1
        Dim layerName As String = ds.GetLayerName(i)
        Debug.WriteLine(layerName)
        Dim ogr As OgrLayer = ds.GetLayer(i)
        AxMap1.AddLayer(ogr, True)
    Next
    AxMap1.ZoomToMaxVisibleExtents()
End If

Is this not what you expected?

image

Regards,
Jerry.

Hi Mr. Jerry,
Thanks for your reply.
I already could load these features in my map. My real problem is that for some reason I need to display only indexes index_100k and index_50k in my map. I somehow want to get the dataset name for each feature class in my OgrDatasource.
Thanks

Ok. Did you see in my sample code that you can get the name on each iteration, and then only load the ones you want. Something like:

Dim ds As New OgrDatasource()
Dim cs As String = "c:\temp\sample\data.gdb"
If ds.Open(cs) Then
    Dim layers As Integer = ds.LayerCount
    For i = layers - 1 To 0 Step -1
        Dim layerName As String = ds.GetLayerName(i)
        Debug.WriteLine(layerName)
        If layerName.Substring(0, 5) = "index" Then
            Dim ogr As OgrLayer = ds.GetLayer(i)
            AxMap1.AddLayer(ogr, True)
        End If
    Next
    AxMap1.ZoomToMaxVisibleExtents()
End If

I don’t know if you’re using VB or c#, but the syntax is similar.

Regards,
Jerry.

Well, this code will solve a particular case when feature class name starts with “index”, but code doesn’t yet solve the problem.
I am using C#

I’m sorry, but this is what I understood you to be saying was the problem. So I guess I don’t understand what you are asking.

Sorry, maybe the way I had written the question does not clearly say it.
To be more clear:
I want the application to enable user to select file geo-database. then application will list all datasets in selected geo-database. Then when user select a particular dataset from drop down list for example, application will list all feature classes within selected dataset.
This is main goal.