Grid Description - 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

A grid surface theme is a continuous raster grid produced by an interpolation of point data. The Create Grid statement takes a data column from a table of points and passes those points and their data values to an interpolator. The interpolator produces a raster grid file, which MapBasic displays as a raster table in a Map window. The Create Grid statement reads (x, y, z) values from the table specified in the From tablename clause. It gets the z values by evaluating the expression specified in the With clause (a column name) with respect to the table and computes a grid cell value using the settings provided for the specific interpolator chosen with these points.

The dimensions of the grid can be specified in two ways. One is by specifying the size of a grid cell in distance units, such as miles, meters, feet, and so on. The other is by specifying a minimum height or width of the grid by number of grid cells. For example, if you wanted the grid to be at least 200 cells wide by 200 cells high, you would specify "cell min 200". Depending on the aspect ratio of the area covered by the grid, the actual grid dimensions might not be exactly 200 by 200, but it would be at least that wide and high.

Example IDW Interpolation with inflections set at certain elevation values:

Open Table "C:\MyData\States.tab" Interactive
Map From States
Open Table "C:\ MyData\Us_elev.tab" Interactive
Add Map Auto Layer Us_elev
Set map redraw off
Set Map Layer 1 Display Off
Set map redraw on
Create Grid 
	From Us_elev 
	with Elevation_FT
	ignore 0 
	into "C:\ MapData\Us_elev_grid.mig" 
	Type "mig.ghl"
	CoordSys Earth Projection 1, 74
	clipping table States 
	Inflect 6 at 
		RGB(64, 0, 128) : -32808 
		RGB(0, 128, 192) : -16404 
		RGB(151, 255, 239) : -98 
		RGB(254, 248, 199) : 33 
		RGB(244, 171, 100) : 6566 
		RGB(235, 95, 1) : 32808 
		round 100	
		cell min 200
	interpolate 
		with "IDW" version "100" 
		using 7 
			"AGGREGATION METHOD": "1"
			"BORDER": "0" 
			"CELL SIZE": "8"
			"EXPONENT": "2" 
			"MAX POINTS": "25" 
			"MIN POINTS": "1" 
			"SEARCH RADIUS": "800"

TIN Interpolator example with inflections set at percentage values:

	inflect 5 by Percent at
		RGB(0, 0, 255) : 0
		RGB(0, 255, 255) : 25 
		RGB(0, 255, 0) : 50 
		RGB(255, 255, 0) : 75 
		RGB(255, 0, 0) : 100 
	Round 10
	cell min 200
interpolate 
	with "TIN" version "100" 
	using 8 
		"BORDER":  "0" 
		"CELL SIZE":  "15"
		"DISTANCE":  "80" 
		"EXPONENT":  "2"
		"FEATURE ANGLE":  "45"
		"SEARCH RADIUS":  "53"
		"TOLERANCE":  "0.01	"
		"READ ONLY":  "T"

Grid Appearance and Inflection Methods

Once the cell values are calculated, MapInfo Pro groups them into a color spectrum that is bounded by the minimum and maximum values in the table defined by the number of inflection color and value pairs defined.

You can control how the color is spread by specifying an inflection method and the number of inflection points. The number of inflections must be between 2 and 255. You can also apply a rounding factor to the inflection values. When interpolating via the user interface, you have four choices of computing inflection values:

  • Equal Cell Count - Sets the inflections so that approximately an equal number of grid cells fall between each inflection value.
  • Equal Value Ranges - Spreads the inflections evenly between the minimum and maximum values of the data range.
  • Custom Cell Count - Use this method to specify your own percentages.
  • Custom Value Ranges - Use this method to specify your own values.

When using the Create Grid statement, you must compute inflection color and values manually using your own methods to compute values from your input data.

Grid Templates

When creating a Grid thematic map in MapInfo Pro, the Grid default template assigns blue to the minimum value and red to the maximum value. These minimum and maximum values are also expressed as percentages of the range. These color settings/values are known as inflection points and will display in the legend with a particular color, value and percentage. If a cell has the exact value as the inflection point, it will display that color on the map. A cell value that falls between two inflection points displays with the color that is in between the colors of those inflection points.

See Also:

IDW Interpolator, TIN Interpolator