# Trend

Interpolates a surface from points using a trend technique.

## Usage tips

Command line and Scripting

• As the order of the polynomial is increased, the surface being fitted becomes progressively more complex. A higher-order polynomial will not always generate the most accurate surface; it is dependent on the data.

• The optional RMS file output contains information on the RMS (root mean square) error of the interpolation. This information can be used to determine the best value to use for the polynomial order, by changing the order value until you get the lowest RMS error. See How Trend works for information on the RMS file.

• For the LOGISTIC option of Type of Regression, the z-value field of input point features should have codes of zero (0) and one (1).

• Some input datasets may have several points with the same X,Y coordinates. If the values of the points at the common location are the same, they are considered duplicates and have no affect on the output. If the values are different, they are considered 'coincident' points. Interpolation functions may handle this data condition differently, in some cases using the first coincident point encountered for the calculation, or sometimes the last. This may cause some locations in the output raster to have different values than what you might expect. The solution is to prepare your data by removing these coincident points.

• The following environment settings affect this tool:

Map Algebra

• As the order of the polynomial is increased, the surface being fitted becomes progressively more complex. A higher-order polynomial will not always generate the most accurate surface; it is dependent on the data.

• The optional RMS file output contains information on the RMS (root mean square) error of the interpolation. This information can be used to determine the best value to use for the polynomial order, by changing the order value until you get the lowest RMS error.

• For the LOGISTIC option, all points in the input point file and point coverage should have codes of zero (0) and one (1).

• GENERATE input files in the POINT format provide an easy method to create surfaces and two-dimensional coverages from ASCII files containing x,y coordinates and z-values. The x,y coordinates and z-values can be expressed as integers or single- or double-precision floating-point values. The x,y coordinates for the output raster are stored in double precision. The z-values are stored in single precision. GENERATE files in the POINT format contain the feature ID, x,y coordinates, and z-values for point features. The ID values are not used by Trend. The format for GENERATE files containing points is:

```     ID,X,Y,Z
...
END
```
The end of the file is indicated with the END keyword. A typical GENERATE file containing points is shown below. The file can be comma or space delimited.
```     1,234.065,837.123,125.845
2,735.774,729.345,93.739
37,840.934,385.700,157.037
5,385.888,286.602,25.764
END
```

• Some input datasets may have several points with the same X,Y coordinates. If the values of the points at the common location are the same, they are considered duplicates and have no affect on the output. If the values are different, they are considered 'coincident' points. Interpolation functions may handle this data condition differently, in some cases using the first coincident point encountered for the calculation, or sometimes the last. This may cause some locations in the output raster to have different values than what you might expect. The solution is to prepare your data by removing these coincident points.

• Trend does not respect the Mask setting.

ArcObjects

• As the order of the polynomial is increased, the surface being fitted becomes progressively more complex. A higher-order polynomial will not always generate the most accurate surface; it is dependent on the data.

• The optional Output RMS file output contains information on the RMS (root mean square) error of the interpolation. This information can be used to determine the best value to use for the polynomial order, by changing the order value until you get the lowest RMS error.

• For the Logistic option of trendType, all points in the input point dataset should have codes of zero (0) and one (1).

• Some input datasets may have several points with the same X,Y coordinates. If the values of the points at the common location are the same, they are considered duplicates and have no affect on the output. If the values are different, they are considered 'coincident' points. Interpolation functions may handle this data condition differently, in some cases using the first coincident point encountered for the calculation, or sometimes the last. This may cause some locations in the output raster to have different values than what you might expect. The solution is to prepare your data by removing these coincident points.

• The output from the ArcObjects method is a raster object.

## Syntax

Trend_sa (in_point_features, z_field, out_raster, cell_size, order, regression_type, out_rms_file)
Parameter Explanation Datatype
Input point features (Required)

The input point features containing z-values to be interpolated into a surface raster.

Composite Geodataset
Z value field (Required)

Field that holds a height or magnitude value for each point.

This can be a numeric field, or the Shape field if the in_point_features contain z-values.

If the regression type is Logistic, the values in the field can only be 0 or 1.

Field
Output raster (Required)

The output raster surface to be created.

Raster Dataset
Output cell size (Optional)

The cell size at which the output raster will be created.

This will be the value in the environment if it is explicitly set. Otherwise, it is the shorter of the width or the height of the extent of in_point_features, in the input spatial reference, divided by 250.

Analysis cell size
Polynomial order (Optional)

The order of the polynomial.

This must be an integer between 1 and 12. A value of 1 will fit a flat plane to the points, and a higher value will fit a more complex surface. The default is 1.

Long
Type of regression (Optional)

The type of regression to be performed.

• LINEAR — Polynomial regression is performed to fit a least-squares surface to the set of input points. This is applicable for continuous types of data.

• LOGISTIC — Logistic trend surface analysis is performed. It generates a continuous probability surface for binary, or dichotomous, types of data.

String
The name of the output containing RMS error and Chi-Square values. (Optional)

Filename for the output text file that contains information about the RMS error and the Chi-Square of the interpolation.

The extension must be ".txt".

File
Data types for geoprocessing tool parameters

Script Example

```# Trend_sample.py
# Description:
#   Interpolate a series of point features onto a rectangular
#   raster using Trend surface interpolation.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005

# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
# Set the output workspace name
gp.Workspace = "C:/data"

# Set the input feature dataset
inputFeatureDataset = "C:/data/pts.shp"

# Set the output raster name
outputRaster = "trend1"

# Set the output extent
gp.Extent = "0 0 6 6"

# Set the attribute field, cellsize, weight and number of points to use
AttributeName = "spot"
CellSize = 1
Polynomial_order = 3
RegressionType = "LINEAR"

# Check out ArcGIS Spatial Analyst extension license
gp.CheckOutExtension("Spatial")

# Process: Trend
gp.Trend_sa(inputFeatureDataset, AttributeName, outputRaster, CellSize, _
Polynomial_order, RegressionType)

except:
# If an error occurred while running a tool, then print the messages
print gp.GetMessages()

```

## Map Algebra syntax

Trend(<point_feature | point_file>, {spot_item}, {order}, {LINEAR | LOGISTIC}, {cellsize}, {xmin, ymin, xmax, ymax}, {rms_file})

Parameter Explanation
<point_feature | point_file> The source of the data containing points with z-values to be converted to a raster surface.
• point_feature — A point coverage or shapefile with z-values stored in an item.
• point_file — An ASCII GENERATE file in the POINT format.
{spot_item} The item in the point coverage to be used as the z-value for the interpolation. The default is an item named SPOT. Use the # symbol as a placeholder when the point locations are input using a <point_file>.
{order} Order of the polynomial. It must be an integer with a value of 1 through 12. A value of 1 will fit a flat plane to the points, and a higher value will fit a more complex surface. The default is 1.
{LINEAR | LOGISTIC} Keywords specifying the type of regression to be performed.
• LINEAR — Polynomial regression is performed to fit a least-squares surface to the set of input points. It is applicable for continuous types of data.
• LOGISTIC — Logistic trend surface analysis is performed. It generates a continuous probability surface for binary, or dichotomous, types of data.
{cellsize} The width or height of a cell in map units. The default is the present environment. If the cell size is not set, an error message will occur. In this case, specify the {cellsize} argument or set the cell size in the analysis environment to establish the current environment setting.
{xmin, ymin, xmax, ymax} The dimensions, in map units, of the window in which to perform the interpolation. The window defaults to the current environment settings. If no environment is set, the default is the boundary of the input extended 0.5 times the cell size in each direction.
{rms_file} The filename for an output text file that contains information about the RMS error of the interpolation.

### Map Algebra example

```trend(pointfile)
trend(pointcov, nest, 2, logistic)
trend(wells, dry, #, logistic, 24)
trend(xmart, client, 1, linear, .25)
con(trend(elev, hills, 3, logistic ) > 2000, 1, 0 )
```

## ArcObjects syntax

IInterpolationOp3:: Trend(geoData As IGeoDataset, trendType As esriGeoAnalysisTrendEnum, order As Long, out_rms_file As String) As IGeoDataset

Parameter Explanation
geoDataset A Featureclass or FeatureclassDescriptor containing point features with z-values to be converted to a raster surface.
trendType An esriGeoAnalysisTrendEnum specifying the type of regression to be performed.
• esriGeoAnalysisLinear — Trend polynomial regression is performed to fit a least-squares surface to the set of input points. It is applicable for continuous types of data.
• esriGeoAnalysisLogisticTrend — Logistic trend surface analysis is performed. It generates a continuous probability surface for binary, or dichotomous, types of data.
[order] Order of the polynomial. It must be an integer with a value of 1 through 12. A value of 1 will fit a flat plane to the points, and a higher value will fit a more complex surface. A commonly used value is 1.
[out_rms_file] The filename for an output text file that contains information about the RMS error of the interpolation.

### ArcObjects example

```' Create the RasterInterpolationOp object
Dim pInterpolationOp As IInterpolationOp
Set pInterpolationOp = New RasterInterpolationOp

' Declare the input feature class object
Dim pInputPoints As IGeoDataset

' Calls function to open a points dataset from disk
Set pInputPoints = OpenFeatureClassDataset ("D:\SpatialData", "inputsamples")

' Declare the output raster object
Dim pOutputRaster As IGeoDataset

' Calls the method
Set pOutputRaster = pInterpolationOp.Trend (pInputPoints, esriGeoAnalysisLinearTrend)
```