Adapted Pair Correlation Function

The adapted pair correlation function transfers the concept of the pair correlation function from point patterns to patterns of objects of finite size and irregular shape (e.g. lakes within a country). This is a reimplementation of the method suggested by Nuske et al. (2009) using the libraries 'GEOS' and 'GDAL' directly instead of through 'PostGIS'.

Travis-CI Build Status AppVeyor Build Status Status Package-License CRAN DOI

The Adapted Pair Correlation Function transfers the concept of the Pair Correlation Function from point patterns to patterns of patches of finite size and irregular shape (eg. lakes within a country). The main tasks are (i) the construction of nullmodels by rondomizing the patches of the original pattern within the study area, (ii) the edge correction by determining the proportion of a buffer within the study area, and (iii) the calculation of the shortest distances between the patches.

This is a reimplementation of the Adapted Pair Correlation Function (Nuske et al. 2009) in C++ using the libraries GEOS and GDAL directly instead of through PostGIS.


For Unix-alikes GDAL (>= 2.0.0) and GEOS (>= 3.4.0) are required.

On Ubuntu bionic (18.04) and beyond one can install the dependencies simply with sudo apt install libgdal-dev libgeos-dev. In earlier Ubuntu version either add ubuntugis-unstable to the sources.list and use above command or compile dependencies from source.


The stable version can be installed from CRAN


and the development is available from Github using the package remotes (formerly devtools)

if(!require("remotes")) install.packages("remotes")


# calculate distances between patches of original pattern and 3 nullmodels
# number of nullmodels should by at least 199 and better yet 999
ds <- pat2dists(area=system.file("shapes/sim_area.shp", package="apcf"),
                pattern=system.file("shapes/sim_pat_reg.shp", package="apcf"),
                max_dist=25, n_sim=3)
# derive PCF and envelope from distances
pcf <- dists2pcf(ds, r=0.2, r_max=25, stoyan=0.15, n_rank=1)
# plot PCF
plot(x=pcf, xlim=c(0, 20), ylim=c(0, 2.2))



Nuske, R.S., Sprauer, S. and Saborowski J. (2009): Adapting the pair-correlation function for analysing the spatial distribution of canopy gaps. Forest Ecology and Management 259(1): 107–116. DOI: 10.1016/j.foreco.2009.09.050


News for Package 'apcf'

Changes in version 0.1.2

  • added to package source bundle
  • clarified installation of stable/development version in README
  • special treatment for R-devel in configure regarding R version check

Changes in version 0.1.1

  • started using continuous integration tools (Travis, AppVeyor, Drone)
  • made it build on windows
  • cleanup and wording

Changes in version 0.1.0

  • Intial version. Reimplementation of the Adapted Pair Correlation Function in C++ using GEOS and GDAL libraries directly instead of through PostGIS. Contains mainly the functions pat2dists(), dists2pcf(), and a plot-function.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.2 by Robert Nuske, 2 months ago

Report a bug at

Browse source code at

Authors: Robert Nuske [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports Rcpp, graphics

Suggests knitr, rmarkdown

Linking to Rcpp

System requirements: C++11, GDAL (>= 2.0.0), GEOS (>= 3.4.0)

See at CRAN