Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public sealed class Table : IDisposable |
Visual Basic (Declaration) |
---|
Public NotInheritable Class Table _ Implements IDisposable |
Remarks
A Table object can be created in a number of different ways depending on the data source type:
- From the Geodatabase.OpenTable method when opening a geodatabase feature class or table.
- From the DataDirectory.OpenTable method when opening a shapefile or dBase table.
- From the static methods on the Table class. To open a geodatabase feature class or table use OpenFileGeodatabaseTable, or OpenArcSDETable. To open a shapefile or dBase file use OpenShapefile.
- From the result of joining two tables together using either Table.Join or TableRelationship.CreateJoinedTable. A common scenario for doing this is where one Table contains only spatial data and another contains attribute data relating to the spatial data. As long as they share a Column, most commonly an ID Column, they can be joined together.
At a basic level a Table is defined by the Columns it contains as these determine what type of data it is capable of storing. A Column is synonymous with a Field, which is a commonly used term in ArcGIS Desktop documentation. The data itself is stored in rows; use the GetRow method to return a specific row by ID or the GetRows method to return all or some of the rows. Alternatively you can query any type of Table using the Search method and for spatially enabled tables you can also use the SearchByDistance method.
You can return the relationships in which a Table participates using the Geodatabase.GetTableRelationships method. To get a specific geodatabase relationship, use the Geodatabase.OpenTableRelationship method. Table performance, particularly when executing queries, is largely governed by the presence of indexes on the appropriate columns; you can use the Indexes property to manage the Table's IndexCollection.
It is important to remember that not all the properties and methods on this class apply to all data types; some only apply to data stored in a geodatabase (check using RootDataContainer property) while others only apply to spatially enabled data types (check using IsSpatial property). For a geodatabase Table you can find out whether it has been subtyped using the IsSubtyped property, which means that the Table has been sub-divided into a number of different categories based on the values in a particular Column (Subtypes). For a spatially enabled Table you can find out what type of geometry it can store (GeometryType), what coordinate system the geometries will be stored in (CoordinateSystem) and return the maximum extent (i.e. bounding box) of all geometries currently in the Table (Extent).
Examples
//Open Forestry file geodatabase Geodatabase gdb = new Geodatabase(@"C:\Data\Forestry.gdb"); //Open the STANDS feature class containing polygons representing the tree stands. Table treeStandsTable = gdb.OpenTable("STANDS"); //Open the COMPONENTS table which contains tree species information for each stand. Table componentsTable = gdb.OpenTable("COMPONENTS"); //Open a ProtectedAreas shapefile of archaeologically sensitive areas. Table protectedAreasTable = Table.OpenShapefile(@"C:\Data\ProtectedAreas.shp"); //Create a List to store ObjectID's List<int> objectIDList = new List<int>(); //Loop over each protected area and perform a spatial query to find the tree //stands which intersect each protected area foreach (Row protectedArea in protectedAreasTable.GetRows()) { Geometry protectedAreaShape = protectedArea.Geometry; RowCollection foundTreeStands = treeStandsTable.Search(new Filter(protectedAreaShape, FilterSearchOptions.Intersects)); //Loop over the found rows foreach (Row treeStand in foundTreeStands) { //The STANDS feature class and COMPONENTS table are related by a 1:M relationship class called //StandsComponents. Use the GetRelatedRows method to find the components which make up each //tree stand. RowCollection components = treeStand.GetRelatedRows("StandsComponents"); foreach (Row component in components) { //Add the ID for each Row to the list objectIDList.Add(component.ObjectID); } } } //Present the results of the analysis in a tabular report TableBindingAdapter bindingAdapter = new TableBindingAdapter(componentsTable); bindingAdapter.Fill(objectIDList.ToArray()); //Create a DataGridView control System.Windows.Forms.DataGridView dataGridView1 = new System.Windows.Forms.DataGridView(); //Set the Datasource to be the bindingSource1 object dataGridView1.DataSource = bindingAdapter;
'Open Forestry file geodatabase Dim gdb As Geodatabase = New Geodatabase("C:\Data\Forestry.gdb") 'Open the STANDS feature class containing polygons representing the tree stands. Dim treeStandsTable As Table = gdb.OpenTable("STANDS") 'Open the COMPONENTS table which contains tree species information for each stand. Dim componentsTable As Table = gdb.OpenTable("COMPONENTS") 'Open a ProtectedAreas shapefile of archaeologically sensitive areas. Dim protectedAreasTable As Table = Table.OpenShapefile("C:\Data\ProtectedAreas.shp") 'Create a List to store ObjectID's Dim objectIDList As List(Of Integer) = New List(Of Integer)() 'Loop over each protected area and perform a spatial query to find the tree 'stands which intersect each protected area For Each protectedArea As Row In protectedAreasTable.GetRows() Dim protectedAreaShape As Geometry = protectedArea.Geometry Dim foundTreeStands As RowCollection = treeStandsTable.Search(New Filter(protectedAreaShape, FilterSearchOptions.Intersects)) 'Loop over the found rows For Each treeStand As Row In foundTreeStands 'The STANDS feature class and COMPONENTS table are related by a 1:M relationship class called 'StandsComponents. Use the GetRelatedRows method to find the components which make up each 'tree stand. Dim components As RowCollection = treeStand.GetRelatedRows("StandsComponents") For Each component As Row In components 'Add the ID for each Row to the list objectIDList.Add(component.ObjectID) Next Next Next 'Present the results of the analysis in a tabular report Dim bindingAdapter As TableBindingAdapter = New TableBindingAdapter(componentsTable) bindingAdapter.Fill(objectIDList.ToArray()) 'Create a DataGridView control Dim dataGridView1 As System.Windows.Forms.DataGridView = New System.Windows.Forms.DataGridView() 'Set the Datasource to be the bindingSource1 object dataGridView1.DataSource = bindingAdapter