# TfNear

Disponible avec une licence Spatial Analyst.

## Synthèse

Defines a Near transformation function which is determined from the midpoint and spread shape–controlling parameters as well as the lower and upper threshold that identify the range within which to apply the function.

## Discussion

The tool that uses the TfNear object is Rescale by Function.

The equation for the Near transformation function is:

The inputs to the equation are f1, the spread, and f2, the midpoint.

The function values range from 0 to 1, which are then transformed to the evaluation scale.

The spread determines how rapidly the transformation function values decrease from the midpoint. If the midpoint is within the lower and upper thresholds, then the spread determines how rapidly the function values decrease from the toScale to the fromScale. The larger the value, the steeper the function values will be around the midpoint. Said another way, as the spread gets smaller, the transformation function values approach the midpoint more slowly. The selection of the appropriate spread value is a subjective process that is dependent on the range of the input values. The default value of 0.1 is a good starting point. Typically, the values vary within the ranges of 0.01 to 1 or 0.001 to 1, respectively. A default spread is calculated to fit the function to the minimum and maximum of the input dataset.

The Near function is useful if you want the highest output evaluation values (the highest preferences) to be assigned to cells with input values near a specific value with the evaluation values (preferences) decreasing as the input values move from the value.

The Near function is similar to the Gaussian transformation function, except the Near function has a narrower spread.

## Syntaxe

`TfNear ({midpoint}, {spread}, {lowerThreshold}, {valueBelowThreshold}, {upperThreshold}, {valueAboveThreshold})`
 Paramètre Explication Type de données midpoint The user-defined value that defines the highest point of the Near transformation function curve. If the midpoint value is between the lower and upper threshold, input cell locations with the corresponding value will receive the toScale evaluation scale value on the output raster.(La valeur par défaut est None) Double spread Defines the spread of the Near function that controls the steepness of the decay of the function from the midpoint. The spread generally ranges from 0.001 to 1; the larger the value results in a steeper decay from the midpoint.(La valeur par défaut est None) Double lowerThreshold Defines the starting value at which to begin applying the specified transformation function. The input value corresponding to the lowerThreshold is assigned to the fromScale evaluation scale value on the output raster. Input values below the lowerThreshold are assigned to the valueBelowThreshold and are not considered in the function value range.The lowerThreshold must be less than the upperThreshold.(La valeur par défaut est None) Double valueBelowThreshold A user-specified value to assign output cell locations with input values below the lowerThreshold. The value for valueBelowThreshold can be float, integer, or NoData. In the tool dialog box, no quotation marks are used around NoData; however, quotation marks are required around "NoData" when scripting.(La valeur par défaut est None) Variant upperThreshold Defines the ending value at which to stop applying the specified transformation function. The input value corresponding to the upperThreshold is assigned to the toScale evaluation scale value on the output raster. Input values above the upperThreshold are assigned to the valueAboveThreshold and are not considered in the function value range.The lowerThreshold must be less than the upperThreshold.(La valeur par défaut est None) Double valueAboveThreshold A user-specified value to assign output cell locations with input values above the upperThreshold. The value for valueAboveThreshold can be float, integer, or NoData. In the tool dialog box, no quotation marks are used around NoData; however, quotation marks are required around "NoData" when scripting.(La valeur par défaut est None) Variant

## Propriétés

 Propriété Explication Type de données midpoint(Lecture et écriture) The value of the midpoint for the transformation function which defines the highest point of the function curve. Double spread(Lecture et écriture) The value of the spread for the transformation function which controls the steepness of the decay of the function from the midpoint. Double lowerThreshold(Lecture et écriture) The value of the lowerThreshold for the transformation function which defines the starting value at which to begin applying the specified transformation function. Double valueBelowThreshold(Lecture et écriture) The value that will be assigned to the output cells whose input values are below the lowerThreshold. Variant upperThreshold(Lecture et écriture) The value of the upperThreshold for the transformation function which defines the ending value at which to stop applying the specified function. Double valueAboveThreshold(Lecture et écriture) The value that will be assigned to the output cells whose input values are above the upperThreshold. Variant

## Exemple de code

Transformation function Near example 1 (Python window)

Demonstrates how to create a TfNear class and use it in the RescaleByFunction tool within the Python window.

``````import arcpy
from arcpy.sa import *
from arcpy import env
env.workspace = "c:/sapyexamples/data"
outRescale = RescaleByFunction("solar", TfNear(180, 0.002, "#", "#", "#", "#"), 1, 10)
outRescale.save("c:/sapyexamples/rescaletfne1")``````
Transformation function Near example 2 (stand-alone script)

Demonstrates how to transform the input data with the RescaleByFunction tool using the TfNear class.

``````# Name: TfNear_Ex_02.py
# Description: Rescales input raster data using a Near function and
#     transforms the function values onto a specified evaluation scale.
# Requirements: Spatial Analyst Extension
# Author: esri

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "solar"

# Create the TfNear object
midpoint = 180
lowerthresh = "#"
valbelowthresh = "#"
upperthresh = "#"
valabovethresh = "#"
myTfFunction = TfNear(midpoint, spread, lowerthresh, valbelowthresh, upperthresh, valabovethresh)

# Set evaluation scale
fromscale = 1
toscale = 10

# Execute RescaleByFunction
outRescale = RescaleByFunction(inRaster, myTfFunction, fromscale, toscale)

# Save the output
outRescale.save("c:/sapyexamples/rescaletfne2")``````