How this calculation works
An empirical variogram summarizes how observed values differ across spatial separation distances and directions. Pairwise half-squared increments form the cloud, and declared bins aggregate those increments into semivariance estimates. The calculation is descriptive: it neither fits a covariance model nor predicts unobserved values by kriging.
gamma_hat(bin)=Σ_{(i,j)in bin}(z_i−z_j)²/(2N_bin); report N_bin and mean pair distance for each bin.A worked example
Four east-west points at x=0,1,2,3with values0,1,2,3give semivariances0.5,2and4.5at distances1,2and3. The corresponding unordered pair counts are3,2and1.
Good to know
3–500 distinct planar coordinates with one finite value each,1–40 increasing distance bins, a cutoff and optional azimuth/tolerance under an explicit north-clockwise convention. Classical semivariance, pair counts and mean distances; empty bins remain undefined. Projected common units only. No longitude/latitude conversion, fitted covariance model, stationarity certification or kriging prediction.
Reference: gstat official sample/residual variogram documentation (opens in a new tab) ↗
Study variation in observed values
Two nearby locations can have similar or different measured values. A variogram summarizes those increments as a function of spatial separation. It is not a point-density or point-clustering statistic: the locations carry marks such as elevation, concentration or another measured variable. Removing those values leaves a different question that Ripley K or other point-pattern methods may address.
The initial estimator averages half the squared value difference for unordered location pairs. Every selected pair contributes one increment, independent of the arbitrary ordering of the two points. A plotted variogram is descriptive evidence about spatial behavior. It does not by itself prove stationarity, isotropy, a causal spatial mechanism or validity of a particular covariance model.
Compare this with the Ripley K and L function calculator for points in a rectangular window. Estimate marked-value semivariance against pair distance/direction and provide the variogram cloud. Ripley K/L measures point-pattern count clustering from locations alone; it cannot use observed values to estimate spatial increment variation.
Prepare locations, units and bin boundaries
Coordinates must be planar and expressed in one common projected unit. Longitude and latitude in degrees do not generally provide Euclidean distances with a consistent physical meaning across a study region. This page does not infer a map projection or silently treat geographic degrees as meters. Duplicate locations also require an explicit replicate or measurement-error model rather than accidental zero-distance pairing.
Bin endpoints divide positive pair distances into declared intervals, with one consistent boundary convention. The first bin begins at zero and subsequent bins follow the entered increasing upper boundaries. The chosen cutoff limits included pairs. Bin width and cutoff affect the apparent smoothness of the summary, so retain them with the output instead of reporting only the plotted curve.
Select directions without double-counting pairs
For directional summaries, azimuth is measured clockwise from north under the stated convention. A pair has an unoriented axis: reversing its endpoints rotates the directed bearing by180degrees but should not alter its directional membership. Angular differences therefore need to be reduced modulo180degrees before comparing with the selected tolerance.
A ninety-degree tolerance includes every unoriented direction and provides an omnidirectional summary. A narrow tolerance may leave few or no pairs in some distance bins. Empty bins are undefined rather than zero semivariance, and sparse bins should remain visibly supported by their pair counts. These bookkeeping details can otherwise create a deceptively smooth but misleading directional plot.
Compute the four-point worked example
The default locations are equally spaced on an east-west line at distances zero through three. Their values are also zero through three. Three adjacent pairs have distance one and squared increment one, so their average half-squared increment is0.5. Two pairs have distance two and squared increment four, giving semivariance two.
Only the first and last points are separated by distance three; their squared increment is nine, giving semivariance4.5. Thus the pair-count sequence is3,2,1and the estimates are0.5,2,4.5. The example makes distance-bin membership, unordered counting and the factor of one half independently visible without needing a fitted spatial model.
Read the cloud alongside binned summaries
The cloud preserves individual pair distances and increments, exposing outlying pairs or broad within-bin variation that a mean can hide. A single unusual measurement can affect many pair increments, so the cloud’s points are not independent observations. An apparently large number of pairs must not be interpreted as the same number of independent sampled locations.
The binned summary reports average pair distance rather than assuming every pair lies at a bin midpoint. It also reports the number of selected pairs. Comparing directional curves requires checking their support and coordinate geometry, not only their heights. Unequal sampling density or a strong trend in values can affect the descriptive result.
Check transformations and independent enumeration
Adding one constant to every measured value leaves all pair differences unchanged. Multiplying values by a factor c multiplies every semivariance by c squared. Scaling coordinates changes distance-bin membership unless the bin endpoints and cutoff are scaled consistently. These are straightforward checks on value handling and physical-unit consistency.
Independently enumerate all i less than j pairs and verify each distance, direction and half-squared increment before aggregation. Compare fixed projected examples with gstat using matching directional and boundary conventions. Test pairs exactly on bin endpoints and azimuth wraparound cases, because an otherwise correct estimator can still misallocate those boundary pairs.
Avoid interpreting a descriptive estimator as a model
A fitted spherical, exponential or other covariance model is not produced here. Choosing such a model requires assumptions and diagnostics beyond calculating empirical increments. Ordinary kriging then uses a specified covariance structure to predict at new locations; a binned variogram alone does not supply that whole prediction procedure or its uncertainty.
Report the coordinate system, measured variable, estimator, bin boundaries, cutoff, azimuth and angular tolerance. A directional pattern can motivate further investigation, but it does not automatically establish physical anisotropy or a stationary spatial process. Preserve empty bins and small pair counts so downstream decisions are based on the actual information available rather than a cosmetically complete line.
A few questions, answered
Is this the same as spatial point clustering?
No. A variogram uses measured values attached to locations. Point-pattern clustering can be studied from locations alone and has different estimators.
Can I use latitude and longitude directly?
The initial scope uses planar projected coordinates with common units. Geographic distances require a separately justified metric or projection.
Why is an empty bin not shown as zero?
No selected pairs means the bin has no semivariance estimate. Zero would incorrectly imply observed agreement.
What happens if I add100to every value?
Nothing changes in the variogram, because every pairwise value difference remains the same.