Purpose
Creates one or more regions by performing a Buffer, Merge, Intersect, Union, Voronoi, or Isogram operation. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Create Object As { Buffer | Isogram | Union | Intersect | Merge |
ConvexHull | Voronoi }
From fromtable
[ Into { Table intotable | Variable varname } ]
[ Data column = expression [ , column = expression... ] ]
[ Group By { column | RowID } ]
fromtable is the name of an open table, containing one or more graphic objects.
intotable is the name of an open table where the new object(s) will be stored.
varname is the name of an Object variable where a new object will be stored.
column is the name of a column in the table.
expression is an expression used to populate column.
Description
The Create Object statement creates one or more new region objects, by performing a geographic operation (Buffer, Merge, Intersect, Union, ConvexHull, Voronoi, or Isogram) on one or more existing objects.
The Into clause specifies where results are stored. To store the results in a table, specify Into Table. To store the results in an Object variable, specify Into Variable. If you omit the Into clause, results are stored in the source table.
The keyword which follows the As keyword dictates what type of objects are created. Buffer and Isogram are discussed in sections: Create Object As Buffer and Create Object As Isogram.
Union
Specify Union to perform a combine operation, which eliminates any areas of overlap. If you perform the union operation on two overlapping regions (each of which contains one polygon), the end result may be a region object that contains one polygon.
The union and merge operations are similar, but they behave very differently in cases where objects are completely contained within other objects. In this case, the merge operation removes the area of the smaller object from the larger object, leaving a hole where the smaller object was. The union operation does not remove the area of the smaller object.
Create Objects As Union is similar to the Objects Combine statement. The Objects Combine statement deletes the input and inserts a new combined object. Create Objects As Union only inserts the new combined object, it does not delete the input objects. Combining using a Target and potentially different tables is only available with the Objects Combine statement. The Combine Objects using Column functionality is only available using Create Objects As Union using the Group By clause.
If a Create Object As Union statement does not include a Group By clause, MapInfo Pro creates one combined object for all objects in the table. If the statement includes a Group By clause, it must name a column in the table to allow MapInfo Pro to group the source objects according to the contents of the column and produce a combined object for each group of objects.
If you specify a Group By clause, MapInfo Pro groups all records sharing the same value, and performs an operation (for example, Merge) on the group.
If you specify a Data clause, MapInfo Pro performs data aggregation. For example, if you perform merge or union operations, you may want to use the Data clause to assign data values based on the Sum() or Avg() aggregate functions.
Intersect
Specify Intersect to create an object representing the intersection of other objects (for example, if two regions overlap, the intersection is the area covered by both objects).
Merge
Specify Merge to create an object representing the combined area of the source objects. The Merge operation produces a results object that contains all of the polygons that belonged to the original objects. If the original objects overlap, the merge operation does not eliminate the overlap. Thus, if you merge two overlapping regions (each of which contains one polygon), the end result may be a region object that contains two overlapping polygons. In general, Union should be used instead.
Convex Hull
The ConvexHull operator creates a polygon representing a convex hull around a set of points. The convex hull polygon can be thought of as an operator that places a rubber band around all of the points. It consists of the minimal set of points such that all other points lie on or inside the polygon. The polygon is convex―no interior angle can be greater than 180 degrees.
The points used to construct the convex hull are any nodes from Regions, Polylines, or Points in the fromtable. If a Create Object As ConvexHull statement does not include a Group By clause, MapInfo Pro creates one convex hull polygon. If the statement includes a Group By clause that names a column in the table, MapInfo Pro groups the source objects according to the contents of the column, then creates one convex hull polygon for each group of objects. If the statement includes a Group By RowID clause, MapInfo Pro creates one convex hull polygon for each object in the source table.
Voronoi
Specify Voronoi to create regions that represent the Voronoi solutions of the input points. The data values from the original input points can be assigned to the resultant polygon for that point by specifying data clauses.
Example
The following example merges region objects from the Parcels table, and stores the resultant regions in the table Zones. Since the Create Object statement includes a Group By clause, MapBasic groups the Parcel regions, then performs one merge operation for each group. Thus, the Zones table ends up with one region object for each group of objects in the Parcels table. Each group consists of all parcels having the same value in the zone_id column.
Following the Create Object statement, the parcelcount column in the Zones table indicates how many parcels were merged to produce that zone. The zonevalue column in the Zones table indicates the sum of the values from the parcels that comprised that zone.
Open Table "PARCELS"
Open Table "ZONES"
Create Object As Merge
From PARCELS Into Table ZONES Data
parcelcount=Count(*),zonevalue=Sum(parcelvalue)
Group By zone_id
The next example shows a multi-object convex hull using the Create Object As statement.
Create Object As ConvexHull from state_caps into Table dump_table