ApplyOverlayTable()
Summary
Computes attribute values for a view using information from an overlay table.
Syntax
rslt = ApplyOverlayTable(string new_view, string overlay_table_filename, string input_view, string output_type, string output_filename, array output_fields, array options)
| Argument | Contents |
|---|---|
| new_view | The desired name for the result view |
| overlay_table_filename | The filename of an overlay table |
| input_view_name | The name of the input view |
| output_type | The type of file to create ("CSV", "dBASE", "FFA" or "FFB") |
| output_filename | The name of the output file |
| output_fields | An array containing one element for each field in the output table. Each element is an array of three items, that indicates the statistic calculated, as shown below |
| Item | Type | Contents |
|---|---|---|
| 1 | String | Name of a field in the input view |
| 2 | String | Statistic: "SUM", "MIN", "MAX", 'DOM" (DOMINANT), "AVG" (AVERAGE), "STDDEV" or "COUNT" |
| 3 (optional) | String | Name of a field in the input view used in computing averages. Necessary only for averages; must be a numeric field |
| Option | Type | Contents |
|---|---|---|
| Missing as zero | N/A | No contents necessary. This option causes all missing numeric values in the input view to be treated as zeros in sum, average, min or max calculations |
Returns
A string containing the name of the view of the new table.
Notes
-
The file types include FFA for fixed-format text (ASCII), FFB for fixed-format binary, and CSV for comma-separated text (values).
-
ApplyOverlayTable() computes attribute values for features in a layer, based on an overlay table that indicates the level of intersection between features in the current layer and features in another layer. The results are written to a new table file, and the table is opened to create a view. The overlay table must be the result of a geographic overlay operation between two area layers (see ComputeIntersectionPercentages()).
-
For numeric fields, you must use the sum, min, max, or average statistic. By default, any missing numeric values in the input view result in a missing value.
-
For string-type input data fields, only the dominant mode is supported. The dominant mode chooses the value from the largest intersecting record.
-
The average statistic calculates weighted averages, and requires a weighting field (this is the optional third field listed above).
-
The output table has one record for each record in the first layer used to create the overlay table.
-
The output table has one column containing the record ID, plus one column for each statistic requested in output_fields.
-
The output_fields array cannot be null.
-
The name, width and number of decimals for all output fields are automatically determined. The name is determined as follows:
| Statistic | Prefix | Example |
|---|---|---|
| Sum | (none) | Income |
| Min | Low | Low Income |
| Max | High | High Income |
| Average | Avg | Avg Income |
Example
// Before running this example, run the ComputeIntersectionPercentages() example,
// and then make sure to create a map by opening manh_zip.cdf in the
// Tutorial folder
folder = RunMacro("G30 Tutorial Folder")
rslt = ApplyOverlayTable("New Overlay Table", folder + "myintersect.dbf",
"5-Digit Zip", "FFB", "folder + "aggtable.bin", { {"White", "Sum", }, {"Population", "Sum", }, {"Population", "Avg", } }, )
Error Codes
| Error Type | Meaning |
|---|---|
| Error | The output_fields array does not have the correct format; one or more of the following input variables is null or invalid: new_view, overlay_table_filename, output_type, output_filename, output_fields; the overlay table is not valid; input_view_name does not correspond to a mappable view; or a file I/O error occurred (e.g., out of disk space) |
| NotFound | The input view does not exist, the input overlay table does not exist, or one of the data fields does not exist |
See Also
| Function | Summary |
|---|---|
| AggregateTable() | Groups records in a view and computes summary statistics |
| ComputeIntersectionPercentages() | Intersects two or more area or line layers and computes the intersection percentages |
| AggregateTable() | Groups records in a view and computes summary statistics |
| ColumnAggregate() | Performs a geographic overlay between two layers and aggregates tabular data |
| MergeByValue() | Creates districts by merging areas from a geographic file, based on the value of a field |
| SelfAggregate() | Groups the records in a view, based on a field, to create an aggregate view |