Product: MapXtreme 2004/2005
Version: 6.0, 6.1, 6.2, 6.5
Platform: Not Platform Related
Category: Tables
Summary:
Creating a column and populating it with the count of features from a table that are within the features of the current table.
Question:
How to create a column and populate it with the count of how many features from a table are within the features of the current table? For example, how many cities are within each state?
Answer:
C# Code:
MapInfo.Data.Columns columns = new MapInfo.Data.Columns();
columns.Add(new MapInfo.Data.Column("NumCities", MapInfo.Data.MIDbType.Int, "Count(State)"));
MapInfo.Data.Table USAtab = MapInfo.Engine.Session.Current.Catalog.GetTable("USA");
MapInfo.Data.Table CitiesTab= MapInfo.Engine.Session.Current.Catalog.GetTable("Cities");
USAtab.AddColumns(columns, MapInfo.Data.BindType.DynamicCopy, CitiesTab, "State", MapInfo.Data.Operator.Equal, "State");
VB.Net Code:
Dim columns As New MapInfo.Data.Columns
columns.Add(New MapInfo.Data.Column("NumCities", MapInfo.Data.MIDbType.Int, "Count(State)"))
Dim USAtab As MapInfo.Data.Table = MapInfo.Engine.Session.Current.Catalog.GetTable("USA")
Dim CitiesTab As MapInfo.Data.Table = MapInfo.Engine.Session.Current.Catalog.GetTable("Cities")
USAtab.AddColumns(columns, MapInfo.Data.BindType.DynamicCopy, CitiesTab, "State", MapInfo.Data.Operator.Equal, "State")
Last Modified: 04/13/2006 02:00:21 PM
|