CreateGrid()

Summary

Creates a geographic file of features on a regular grid.

Changes

In Version 5.0 the Field Width and Format options are no longer available.

Syntax

max_weight = CreateGrid(real x_origin, real y_origin, integer num_rows,integer num_cols, real x_step, real y_step, string new_db_name, string layer_type, array options)

Argument Contents
x_origin Local X coordinate of the grid's origin, in millionths of degrees
y_origin Local Y coordinate of the grid's origin, in millionths of degrees
num_rows Number of rows in the grid
num_cols Number of columns in the grid
x_step Local X coordinate increment between columns in the grid, in millionths of degrees
y_step Local Y coordinate increment between rows in the grid, in millionths of degrees
new_db_name The path and file name of the new geographic file
layer_type The type of features to create: Point, Line, or Area
Option Type Contents
Density Array Array of four elements; only works for rectangular areas:- String layer|set: source points- String fieldname: field with values- String type: "Quartic" (approximating to Normal-Gaussian), "Triangular", or "Uniform")- Real radius (search radius in current user units; also call bandwidth)
Hexagonal Boolean Create a hexagonal grid (defaults to "False")
Label String A descriptive label for the geographic file
Layer Name String The name of the layer in the geographic file
Median Split Boolean If "True" special handling ensures that entities which cross the 180 degree longitude line are created properly; if "False" (the default), no special handling is invoked
NAD Conversion 3 strings Input datum, output datum, and conversion file (if needed); the input and output datums should be different
Node Layer Name String The desired name for the endpoint layer (only when creating a line layer)
Optimize Boolean Whether to optimize the geographic file automatically after creation (defaults to "True")
Projection String, array The projection name and the array of options
Shape Points Integer Number of shape points per grid edge (only for line and area layers); minimum of 2 (defaults to 10)
Table Filename String The path and file name in which attributes are stored; the file extension must be .BIN, .CSV, .DBF, or .TXT; a required option
Temp Path String The path and file name for temporary files
Transform Array Array indicating the transformation to apply to coordinates in the file. This can have two forms:(1) an array of two or more four-element arrays containing local and world coordinates for control points, for example, {{real localX1, real localY1, real longitude1, real latitude1}, ...}.(2) an array of four elements: {real X_multiplier, real Y_multiplier, real X_offset, real Y_offset}

Returns

The maximum weight, only returned when the Density option is used

Notes

  • If the Projection option is not used then a non-projected grid is generated.

  • The coordinate increments must be positive.

  • Point grid CDFs are supported when new_db_name ends in .cdf.

    • CDFs are faster and more efficient than DBDs and are the preferred output geographic file type.

  • For more details on the NAD Conversion option, see Datum Conversions.

  • For more details on the Projection option, see Using Projections and Coordinate Systems.

  • CreateGrid() displays a progress bar. To add a Cancel button to the progress bar, precede the function call with an "on escape" clause. For more information, see Error Handling.

  • The origin of the grid will be in the southwest corner.

Examples

// A 30-arcsecond longitude-latitude point grid
step = (30/3600) * 1000000 // In millionths of degrees
origin_lon = -72000000 // longitude in millionths of degrees
origin_lat = 42000000 // latitude in millionths of degrees
folder = RunMacro("G30 Tutorial Folder")
CreateGrid(origin_lon, origin_lat, 10, 10, step, step, folder + "mygrid1.CDF", "Point",{
{"Label", "30-arcsecond Grid"},
{"Layer Name", "Grid"},
{"Optimize", "True"},
{"Table Filename", folder + "mygrid1.bin"}
})
// Open mygrid1.dbd in the Tutorial folder to see the results.
// A UTM line grid
folder = RunMacro("G30 Tutorial Folder")
CreateGrid(300000, 4650000, 100, 100, 10000, 10000, folder + "mygrid2.CDF", "Line",
{
{"Label", "UTM Grid"},
{"Layer Name", "Grid"},
{"Optimize", "True"},
{"Projection", "utm", {"zone=19", "units=m"}},
{"Shape Points", 8},
{"Table Filename", folder + "mygrid2.bin"}
})
// Open mygrid2.dbd in the Tutorial folder to see the results.
// A 30-arcsecond longitude-latitude point grid
step = (30/3600) * 1000000 // In millionths of degrees
origin_lon = -72000000 // longitude in millionths of degrees
origin_lat = 42000000 // latitude in millionths of degrees
folder = RunMacro("G30 Tutorial Folder")
CreateGrid(origin_lon, origin_lat, 180, 360, step, step, folder + "mygrid3.dbd",
"Line",{
{"Label", "1 Degree Grid"},
{"Layer Name", "1 Degree Grid"},
{"Optimize", "True"},
{"Table Filename", folder + "mygrid3.bin"}
})
// Open mygrid3.dbd in the Tutorial folder to see the results.

Error Codes

Error Type Meaning
Error An argument or option has the wrong type or the wrong number of values
Escape The user clicked Cancel

See Also

Function Summary
ImportCSV() Imports features from a Caliper text geography file into a geographic file