Create Object As Buffer - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Creates a polygon boundary around points, lines, or other boundaries. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Create Object As Buffer 
	From fromtable 
	[ Into { Table intotable | Variable varname } ] 
	[ Width bufferwidth [ Units unitname ]]]
	[ Type { Spherical | Cartesian } ] ] 
	[ Resolution smoothness ] 
	[ Data column = expression [ , column = expression... ] ] 
	[ Group By { column | RowID } ] 
	[ Concurrency { All | Aggressive | Intermediate | Moderate | None } ]
	

bufferwidth is a number indicating the displacement used in a Buffer operation; if this number is negative, and if the source object is a closed object, the resulting buffer is smaller than the source object. If the width is negative, and the object is a linear object (line, polyline, arc) or a point, then the absolute value of width is used to produce a positive buffer.

unitname

smoothness is an integer from 2 to 100, indicating the number of segments per circle in a Buffer operation.

Description

If the Create Object statement performs a Buffer operation, the statement can include Width and Resolution clauses. The Width clause specifies the width of the buffer. The optional Units sub-clause lets you specify a distance unit name (such as "km" for kilometers) to apply to the Width clause. If the Width clause does not include the Units sub-clause, the buffer width is interpreted in MapBasic's current distance unit. By default, MapBasic uses miles as the distance unit; to change this unit, use the Set Distance Units statement.

Type is the method used to calculate the buffer width around the object. It can either be Spherical or Cartesian. Note that if the coordinate system of the intotable is NonEarth, then the calculations are performed using Cartesian methods regardless of the option chosen, and if the coordinate system of the intotable is Latitude/Longitude, then calculations are performed using Spherical methods regardless of the option chosen.

The optional Type sub-clause lets you specify the type of distance calculation used to create the buffer. If the Spherical type is used, then the calculation is done by mapping the data into a Latitude/Longitude On Earth projection and using widths measured using Spherical distance calculations. If the Cartesian type is used, then the calculation is done by considering the data to be projected to a flat surface and widths are measured using Cartesian distance calculations. If the Width clause does not include the Type sub-clause, then the default distance calculation type Spherical is used. If the data is in a Latitude/Longitude projection, then Spherical calculations are used regardless of the Type setting. If the data is in a NonEarth projection, the Cartesian calculations are used regardless of the Type setting.

The Resolution keyword lets you specify the number of segments comprising each circle of the buffer region. By default, a buffer object has a smoothness value of twelve (12), meaning that there are twelve segments in a simple ring-shaped buffer region. By specifying a larger smoothness value, you can produce smoother buffer regions. Note, however, that the larger the smoothness value, the longer the Create Object statement takes, and the more disk space the resultant object occupies.

The optional Concurrency clause lets you distribute the processing to multiple cores to improves performance. When Concurrency is set to none and the machine has more than one core, then the other cores are left unused. This clause lets you specify the level of concurrency needed to perform this operation on the map. Concurrency can have one of the following values:
  • All: Full concurrency. All processors on your system perform the operation. This is the default setting MapInfo Pro installs with.
  • Aggressive: Aggressive concurrency, 75% of the processors on your system perform the operation.
  • Intermediate: Intermediate concurrency, 50% of the processors on your system perform the operation.
  • Moderate: Moderate concurrency, 25% of the processors on your system perform the operation.
  • None: No concurrency. A single processor performs the operation. This option provides the least amount of processing speed.

For example:


Create Object As Buffer 
	From zipcodes 
	Width 1 
	Units "mi" 
	Type Spherical 
	Resolution 12 
	Into Table zipcodes 
	Group by Rowid  
	Concurrency Aggressive
	Data...

In addition to the five possible concurrency values, you can also specify the number of cores to use, such as eight (8). If your computer has less than the specified number of cores, MapBasic defaults to using all available cores on that machine. Specifying zero (0), a negative number, or invalid text that is different from the five possible concurrency values causes an error.

The following commands display an error message:

Create Object As Buffer 
	From zipcodes 
	Width 1 
	Units "mi" 
	Type Spherical 
	Resolution 12 
	Into Table zipcodes 
	Group by Rowid  
	Concurrency 0
Create Object As Buffer 
	From zipcodes 
	Width 1 
	Units "mi" 
	Type Spherical 
	Resolution 12 
	Into Table zipcodes 
	Group by Rowid  
	Concurrency -5
Note: You can only use concurrency if the One buffer for each object option is selected in the Buffer Objects dialog box. If this option is not selected and you specify the Concurrency clause, then it is ignored and there is no error message.

If a Create Object As Buffer statement does not include a Group By clause, MapInfo Pro creates one buffer region. If the statement includes a Group By clause which names a column in the table, MapInfo Pro groups the source objects according to the contents of the column, then creates one buffer region for each group of objects. If the statement includes a Group By RowID clause, MapInfo Pro creates one buffer region for each object in the source table.

Example

The next example creates a region object, representing a quarter-mile buffer around whatever objects are currently selected. The buffer object is stored in the Object variable, corridor. A subsequent Update statement or Insert statement could then copy the object to a table.

Dim corridor As Object
Create Object As Buffer
	From Selection 
	Into Variable corridor
	Width 0.25 Units "mi" 
	Resolution 60 

See Also:

Set Buffer Version statement