TPI Neighborhood Sampler

Topographic Analysis · TPI Tools · interactive window · by Jeff Jenness
Works at every ArcGIS Pro license level

Summary

Over the years, the most common question I get regarding TPI is what neighborhood size would work best. The second most common is whether someone should use raw TPI values to classify landforms, or if they should use neighborhood standard deviations. I've always had to respond that I don't know of any foolproof way to do it, so they should just find some topographic feature they know that they want classified a particular way, and try lots of variations until that feature is classified correctly.

This tool attempts to help implement that in a way that is much faster than running the tool a bunch of times. You can take a snapshot of an area you know you want classified a certain way, then use an interactive window with sliders to test different neighborhood sizes and class threshold values. In order to make the tool quick and responsive, it currently only offers circular neighborhoods (not annuli), and it only tests the raw TPI and neighborhood standard deviation methods (not percentiles or full DEM standard deviations). It also might be working from a coarser copy of the source elevation data than the DEM you are using, but it will still give you a good illustration of the consequences of a wide range of settings.

The settings found here go straight into the Topographic Position Index tool, the Slope Position Classification and Landform Classification tools, and the thresholds of a system built in the Classification System Builder. The window adds nothing to the map and writes nothing to disk: the snapshot lives in memory and is gone when the window closes.

How it works

Zoom the map to a piece of terrain that holds a feature you know how you want classified, a hill that should come out as a hill or a drainage that you want classified as a valley, with enough of the surrounding landscape in view to hold the largest neighborhood you might try. Then click TPI Neighborhood Sampler in the TPI Tools row of the Topographic Analysis Tools gallery.

The Topographic Analysis Tools gallery open on the ribbon, with the TPI Neighborhood Sampler button, in the TPI Tools row, outlined in blue
Where to find it: TPI Neighborhood Sampler is in the TPI Tools row of the Topographic Analysis Tools gallery, in the Topographic Analysis group of the Wildlife and Forestry tab.
  1. Take a snapshot. Choose the DEM from the map's raster layers, pick a snapshot resolution (either 200, 400 or 800 pixels on the longest edge) from the Detail box, and then click Take Snapshot. The tool reads the part of the DEM inside the view into a coarse grid of that size, computes the TPI for the smallest and the largest neighborhoods to set the scales, and paints the picture. The line of text beside the button says what the snapshot is: for instance 400 × 300 cells of about 90 m (3 × 3 DEM cells, averaged).
  2. Slide the neighborhood. The slider under the picture is the neighborhood radius. Each step is half a snapshot cell, and the picture repaints as the slider moves, showing the TPI for that neighborhood over the whole snapshot. The grids for every step are computed in the background right after the snapshot, so the slider never waits. Type an exact radius in the Radius box to use a value between the steps.
  3. Slide the threshold. The slider standing on the left is the classification threshold. The black line in the picture is drawn where the TPI equals it, and the cells on the side you chose under The feature I want is are tinted yellow. Move both sliders until the feature you have in mind is tinted and the things that should not be are not.
  4. Pin the feature. Click the feature in the picture, zooming in with the mouse wheel first if the feature is small. A crosshair marks the cell, and the Pinned feature panel plots that cell's TPI against the neighborhood radius, with the threshold as a line across the plot and the radii that classify the cell as the feature shaded. A sentence under the plot says the same thing in words: This cell is the feature at this threshold for radii from 720 to 5,400 meters.
  5. Copy the settings. Copy Settings puts the neighborhood, the TPI scale and the threshold on the clipboard as text, followed by the Python call that computes the same TPI with the Topographic Position Index tool.

Pan or zoom the map and click Take Snapshot again for a new piece of terrain; the window stays open.

An example: a small mountain

Suppose I want a slope position classification that captures a particular small mountain I have in mind. I can see it in my map, but I can also see it in the TPI Neighborhood Sampler window by selecting the DEM, taking a snapshot with the hillshade turned on, and turning the neighborhood radius all the way to the left, where the picture is nearly all hillshade. I have circled the hill I want to capture:

The TPI Neighborhood Sampler window with a snapshot of 625 by 548 cells of about 90 m, the neighborhood radius at its minimum of 90 m, No classification chosen and the hillshade on, so the picture is a gray shaded relief of valleys and ridges. A small oval mountain near the bottom center is circled in blue
The snapshot at the smallest neighborhood, one snapshot cell, is nearly all hillshade. The small mountain to capture is circled.

I can turn off the classification line initially and explore the effect of the neighborhood radius alone:

The picture with No classification at a radius of 4,095 m: deep red over the mountain ranges, blue in the basins and drainages between them, and the small mountain a solid red island in a pale basin
No classification, at a radius of 4,095 m. Red is above the neighborhood mean, blue below. At this radius the small mountain stands out as a red island.

Then I can turn on the classification threshold and try some variations:

The same picture with a threshold applied: the cells above it are tinted orange with a black outline, taking in the mountain ranges and the small mountain as separate islands
The same radius with a threshold applied. The tinted islands are the cells that would be classified as the feature.

Better yet, I can roll my mouse wheel to zoom in and set a pin at about the place where I want the terrain to transition into my class, and set my threshold and neighborhood radius so that the pinned cell is just inside it:

The window zoomed 3.8 times on the small mountain, which fills the picture as an orange tinted island with a black outline; a red crosshair pin sits on its lower western flank just inside the outline. The radius is 4,275 m and the threshold 8.792 elevation units. The Pinned feature panel reads: column 319, row 387, elevation 1,215.4; at the current radius its TPI is 12.9 elevation units: it IS the feature; and the plot shows the cell's TPI dipping below zero at middle radii and climbing past the threshold near the right, with the shaded span from 4,185 to 5,400 meters
Zoomed in on the mountain with a pin on its lower flank. The plot shows the pinned cell's TPI at every radius: below the threshold for the smaller neighborhoods, above it only from 4,185 m up. At 4,275 m and a threshold of 8.79 the pinned cell is just inside the class.

Then I click Copy Settings and paste it into Notepad, and follow the instructions in that message:

Notepad showing the pasted settings: DEM dem_m_clip; neighborhood circle, radius 4,275 meters (142 DEM cells, 48 snapshot cells); TPI scale raw; classify as the feature TPI at or above 8.79 elevation units; the snapshot size; then the Python lines that import the toolbox and call arcpy.jenness.SimpleTPI with in_raster, out_tpi, nb_shape Circle, nb_outer 4275 and nb_units Meters, and a closing comment to classify cells at or above 8.79 or to put the threshold in a classification system
The settings on the clipboard: the choices in words, then the Python call that computes the same TPI with the Topographic Position Index tool.

You can also draw the symmetric opposite threshold, the negative of the current number, with Also draw the line at minus the threshold. The dashed blue line shows where the same rule would classify valleys, so both sides of a symmetric classification can be seen at once:

The picture at a radius of 4,275 m with the threshold line in black around the tinted ridges and mountains and a dashed blue line at minus the threshold enclosing the basins and drainages, which are deep blue around the north-eastern range and pale blue through the central valley
The line at minus the threshold, dashed blue, encloses the valleys the same rule would classify on the other side.

The window

ControlMeaning
DEM The elevation raster to sample, from the raster layers of the active map. A raster layer selected in the Contents pane when the window opens is chosen to start with. The refresh button beside the list reads it again after a layer is added. The active view must be a map, not a layout.
Detail The snapshot's size in cells along its longer side: 200, 400 or 800. More detail shows smaller features and takes a little longer to read and compute. Zooming the map in is the other way to get finer cells.
Take Snapshot Reads the DEM inside the current view and paints the first picture.
Threshold slider Standing on the left of the picture. Its reach is set from the snapshot: a round number at or above the largest TPI found at the smallest and the largest neighborhoods, so it does not change as the radius moves. In the standard deviation scale it runs from −3 to +3.
Neighborhood radius slider Lying under the picture, from one snapshot cell to 60 snapshot cells or a third of the snapshot's shorter side, whichever is less, in steps of half a cell. The label under it gives the radius in the chosen units, in DEM cells and in snapshot cells.
Radius units Cells, Meters, Kilometers, Feet or Miles, the same list the TPI tools offer. Cells are the DEM's own cells, not the snapshot's. Changing the units keeps the same radius on the ground.
Radius The radius as a number, for typing an exact value. Press Enter; the slider follows. A value more than one and a half times the slider's end is trimmed, with a note to zoom the map out and take a larger snapshot.
TPI scale Raw TPI, in the DEM's elevation units: the cell's elevation minus the mean elevation of its neighborhood, what the Topographic Position Index tool writes to its first output. Neighborhood standard deviations: the raw TPI divided by the standard deviation of elevation within the same neighborhood, the tool's standardized at neighborhood scale output and the sd units of a classification system. Each scale remembers its own threshold.
Threshold value The threshold as a number. Press Enter; the slider follows. A value beyond the slider's reach is allowed.
The feature I want is At or above the threshold tints the cells whose TPI is at or above it, for hills and ridges. At or below it tints the cells at or below, for valleys and channels. The line is the same either way. No classification draws no line and no tint, so the picture shows only the TPI colors as the radius changes; the threshold controls rest until a side is chosen again.
Also draw the line at minus the threshold Draws a second, dashed blue line where the TPI equals the negative of the threshold. Ridge and valley thresholds are usually chosen together, and Weiss's classes are symmetric.
Light the TPI with a hillshade Shades the colors with a hillshade computed from the snapshot, for a sense of the terrain under the TPI.
Tint the cells that pass the threshold The yellow tint. With it off only the line is drawn.
Zooming the picture The mouse wheel zooms the picture about the pointer, up to 32 times, so a pin can be placed on exactly the cell wanted; the cells show as blocks when zoomed in. Drag with the middle or the right mouse button to pan. Full Extent shows the whole snapshot again, as does a new snapshot.
Pinned feature The pinned cell's column, row and elevation, its TPI at the current radius and whether that makes it the feature, the plot of TPI against radius, and the sentence naming the radii that classify it as the feature. Clear Pin removes the pin, and What is this? beside the heading opens a short explanation of the panel and of zooming the picture.
Copy Settings The settings and the matching Python call, to the clipboard.

Reading the picture

The colors are the TPI: white at zero, deepening to red for cells above their neighborhood mean and to blue for cells below it. The colors saturate at a round number near the top of the range found in the snapshot, so a very tall hill and a merely tall one are both full red, and the same color means the same TPI at every radius. The black line is the threshold, traced through the cells by linear interpolation. The yellow tint marks the cells on the chosen side of it. Cells with no data are left blank.

A band along the edge of the snapshot, as wide as the radius, is drawn faded. The neighborhoods of those cells run off the snapshot, so their TPI is computed from what is inside and may not match what the full DEM would give. As the radius grows, so does the band; if the feature of interest sits in it, zoom the map out and take a new snapshot with more room around it. The last figure of the example above shows the faded band, the threshold line and the dashed line at minus the threshold together.

The pinned feature

The sliders show what happens to the whole snapshot; the pin answers the question for one place. Click the crest of the hill you have in mind, and the plot on the right shows its TPI at every radius the slider can reach, from one snapshot cell to the end of the slider. The threshold is the horizontal line, the current radius the vertical one, and the radii that classify the cell as the feature are shaded. A small sharp hill rises above the threshold at a modest radius and stays there; a hill on the flank of a larger ridge rises and then falls again as the neighborhood grows to take in the ridge, and the shaded span shows exactly where. Pin the places that must come out one way, then the places that must come out the other, and the settings that satisfy both are the ones to use.

The Pinned feature panel: the words Pinned cell: column 319, row 387, elevation 1,215.4. At the current radius its TPI is 12.9 elevation units: it IS the feature; a plot with a red curve that starts near zero, dips below the dotted zero line, then climbs past the black threshold line near the right edge, where a yellow band marks the span of radii, with the axis labeled 90 at the left and 5,400 meters at the right; and under it: This cell is the feature at this threshold for radii from 4,185 to 5,400 meters
The pinned feature panel for the cell on the mountain's flank in the example: its TPI against the radius, the threshold as the black line, the current radius as the gray one, and the radii that classify it as the feature shaded.

The snapshot and its cells

The snapshot is coarser than the DEM so that the arithmetic is quick enough to follow a slider. Its cell is a whole number of DEM cells on a side, chosen so the longer side of the view fits the chosen detail: a view 1,200 DEM cells wide at a detail of 400 gives snapshot cells of 3 × 3 DEM cells. Each snapshot cell is the mean of its block of DEM cells, which is the right aggregation for a quantity defined by neighborhood means. A view of more than about 36 million DEM cells is sampled at the center of each block instead of averaged, and the readout says so. A block that is more than half NoData is NoData.

Radii are converted through the true ground size of a snapshot cell, so a radius of 1,500 meters is 1,500 meters whatever the detail. On a DEM in geographic coordinates the cells are measured on the spheroid: the east-west radius in cells changes from row to row with the latitude, so that the neighborhood is a circle on the ground, the same convention the Topographic Position Index tool uses. The neighborhood itself is the tool's circular neighborhood, cell for cell, at the snapshot's resolution.

What the coarse cell costs is detail. Relief smaller than a snapshot cell is averaged away, so a narrow knob reads a little lower than it would at full resolution, and a thin channel a little shallower; the raw thresholds found here may want a small adjustment when the full tool runs on the native DEM, while the neighborhood size transfers as it is. Zoom the map in, or raise the detail, when the feature of interest is only a few snapshot cells across.

What it does not do

Taking the settings to the tools

Copy Settings writes something like this to the clipboard:

TPI Neighborhood Sampler settings
DEM: Coconino_30m
Neighborhood: circle, radius 1,500 meters (50 DEM cells, 16.7 snapshot cells)
TPI scale: raw TPI, in the DEM's elevation units
Classify as the feature: TPI at or above 12.5 elevation units
Snapshot: 400 × 300 cells of about 90 m (3 × 3 DEM cells, averaged)

# Python: the same TPI with the Topographic Position Index tool
import arcpy
arcpy.ImportToolbox(r"C:\path\to\JennessEnterprisesTools.pyt")  # your installed path is shown in the tool's run messages
arcpy.jenness.SimpleTPI(
    in_raster=r"Coconino_30m",
    out_tpi=r"C:\data\tpi_1500.tif",
    nb_shape="Circle",
    nb_outer=1500,
    nb_units="Meters")
# then classify the feature as cells >= 12.5 in that raster, or put the threshold in a classification system

In the Topographic Position Index tool, the neighborhood shape, radius and units are the same three settings, and the raw scale is the first output, the standard deviation scale the second. In the Slope Position Classification and Landform Classification tools, enter the radius and units in the on-the-fly neighborhood and choose Raw or Neighborhood SD as the TPI type. The threshold belongs in a classification system: open the Classification System Builder, give the class a criterion on the TPI input in raw or sd units with the value found here, and the tools apply it.

Recommended citation

Jenness, J. 2026. TPI Neighborhood Sampler. Wildlife and Forestry Tools add-in for ArcGIS Pro, v. 1.103 (October 2026). Jenness Enterprises. Available at: https://github.com/JeffJenness/Wildlife_Tools.

Credits

By Jeff Jenness, Jenness Enterprises (www.jennessent.com). The Topographic Position Index and its neighborhood-scale standardization are described on the About TPI page, with the references.

Licensing information

Works at every ArcGIS Pro license level (Basic, Standard, Advanced). No extension licenses are required.