Spatial Data Science & GeoAI

lctools


Local and Geographically Weighted Spatial Statistics Tools

The main purpose of the R package lctools is to provide researchers and educators with easy-to-learn, user friendly tools for calculating key spatial statistics and for applying simple as well as advanced methods of spatial analysis on real data. These include: Local Pearson and Geographically Weighted Pearson Correlation Coefficients; Spatial Inequality Measures (Gini coefficient, Spatial Gini, Location Quotient and Focal Location Quotient); Spatial Autocorrelation indices (Global and Local Moran’s I); several Geographically Weighted Regression techniques, including the Geographically Weighted Zero-Inflated Poisson Regression; tools for computing variables used in Spatial Interaction Models; and other geographically weighted statistics. The local correlation tools were originally developed to test for local multicollinearity among the explanatory variables of local regression models and can also be used to examine the local association between pairs of variables. The package also contains functions for measuring the significance of each statistic calculated, mainly based on Monte Carlo simulations, and comes with two example datasets, one of which is a spatial data frame referring to the municipalities of Greece.

Available in CRAN @ https://CRAN.R-project.org/package=lctools

Install the latest version from R with:

install.packages("lctools")

Current release: version 0.3 (9 July 2026). Requires R ≥ 3.5.0. The package imports spreshapeweightspscl and MASS.

Main functions and data

  • lcorrel: Local Pearson and Geographically Weighted Pearson correlation coefficients, with mc.lcorrel for Monte Carlo significance testing
  • moransImoransI.wmoransI.v: Global Moran’s I for assessing spatial autocorrelation (standard, with a ready-made weights matrix, or for a set of bandwidths)
  • l.moransI: Local Moran’s I with a Moran’s I scatter plot
  • spGinispGini.w: Spatial decomposition of the Gini coefficient, with mc.spGini for Monte Carlo significance testing
  • FLQ: Location Quotients and Focal Location Quotients
  • gwrgwr.bw: Geographically Weighted Regression (GWR) and optimal bandwidth selection
  • gw.glmgw.glm.bwgw.glm.mc.test: Generalised Geographically Weighted Regression (GGWR), optimal bandwidth selection and a significance test for the spatial variation of the local parameter estimates
  • gw.zigw.zi.bwgw.zi.mc.test: Geographically Weighted Zero-Inflated Poisson Regression (GWZIPR), optimal bandwidth selection and a significance test for the spatial variation of the local parameter estimates
  • w.matrixlat2w: Spatial weights matrices (nearest neighbours or fixed distance; contiguity on a regular grid)
  • accgw_variable: Variables for Spatial Interaction Models (destination accessibility; regional or geographically weighted variables)
  • random.test.data: Synthetic spatial data generator for testing
  • GR.Municipalities: Municipalities of Greece in 2011 (spatial data frame) and VotesGR: New Democracy and total votes in Greece in 2012 (datasets)

Changelog

Version: 0.3 (9 July 2026)

CRAN: lctools is back on CRAN. Version 0.3 is a resubmission that resolves all outstanding CRAN checks (new Authors@R field, package anchors in Rd cross-references, xz compression for the example datasets, relaxed dependency to R ≥ 3.5.0).

Title: New package title “Local and Geographically Weighted Spatial Statistics Tools” and an expanded package description.

Vignettes: The two vignettes (Spatial Autocorrelation, Spatial Inequalities) are now built as HTML instead of PDF, removing the LaTeX requirement and reducing package size; an obsolete reference to the retired rgdal package was removed.

Tests: New testthat suite (26 assertions) covering lat2ww.matrixmoransImoransI.wspGinispGini.w and random.test.data, including the consistency of the two Moran’s I implementations and the additivity of the spatial Gini decomposition.

Code: Minor cleanup in random.test.data and lat2w; behaviour unchanged.

Documentation: Spelling corrections and fixed links in the help pages.

Version: 0.2-10 (2 April 2024)

Maintenance: Updated package metadata (new website https://stamatisgeoai.eu and maintainer email), dependency update to R ≥ 4.3.0, rmarkdown added to suggested packages.

Version: 0.2-8 (6 April 2020)

Code: Bug fixes, update dependencies with other packages and data directory to comply with CRAN policies

Version: 0.2-7 (23 April 2019)

Code: Bug fixes, checks to comply with CRAN policies

Version: 0.2-6 (5 August 2017)

gw.glm.mc.test: Significance test for the spatial variation of the GGWR local parameter estimates

Documentation: Mistake corrections, improved equations

Contact: New website with contact form and new email

Version: 0.2-5 (3 September 2016)

moransI.v: Computes a vector of Moran’s I statistics (using a set of bandwidths; fixed or adaptive spatial kernels)

l.moransI: updated to draw a Moran’s I Scatter Plot

Code: Bug fixes

Vignettes: Updated Spatial Autocorrelation vignette

References: Updated broken links and list of references

Version: 0.2-4 (20 December 2015)

gw.glm.bw: Optimal bandwidth estimation for Generalised Geographically Weighted Regression (GGWR)

gw.glm: Generalised Geographically Weighted Regression (GGWR)

gw.zi.bw: Optimal bandwidth estimation for Geographically Weighted Zero Inflated Poisson Regression (GWZIPR)

gw.zi.mc.test: Significance test for the spatial variation of the GWZIPR local parameter estimates

gw.zi: Geographically Weighted Zero Inflated Poisson Regression (GWZIPR)

gwr.bw: Optimal bandwidth estimation for Geographically Weighted Regression (GWR)

gwr: Geographically Weighted Regression (GWR)

random.test.data: Radmom data generator

spg.sim.test: Simulation test (Rey & Smith, 2013)

lat2w: Contiguity-based weights matrix for a regular grid

Version: 0.2-3 (5 July 2015)

moransI.w: Moran’s I classic statistic for assessing spatial autocorrelation using a ready made weights matrix

spGini.w: Spatial Gini coefficient with a given weights matrix

w.matrix: Weights Matrix based on a fixed number of nearest neighbours

Code: Bug fixes

Version: 0.2-2 (15 April 2015)

Documentation: Vignettes on spatial autocorrelation and spatial inequalities

Code: Bug fixes, somewhat improved code efficiency (and thus speed)

Version: 0.2 (5 April 2015)

l.moransI: Local Moran’s I classic statistic for assessing spatial autocorrelation

GR.Municipalities: Municipalities in Greece in 2011 (data from 2001 Census).

Datasets removed: GreeceNew, GreeceLAs

Version: 0.1-3 (29 July 2014)

mc.lcorrel: Monte Carlo simulation for the significance of the local correlation coeficients

mc.spGini: Monte Carlo simulation for the significance of the Spatial Gini coefficient

moransI: Moran’s I classic statistic for assessing spatial autocorrelation

Version: 0.1-2 (24 April 2014)

spGini: spatial decomposition of the Gini (Rey and Smith, 2013)

FLQ: Location Quotients and Focal Location Quotients (Cromley and Hanink, 2012)

VotesGR: New Democracy and Total Votes in Greece in 2012 at NUTS III level of geography

Version: 0.1-1 (23 January 2014)

The main purpose of the R package lctools is to help testing the existence of local multi-collinearity among the explanatory variables of local regression models. The main function (lcorrel) allows the computation of Local Pearson and Geographically Weighted Pearson Correlation Coefficients and tests for their significance.

lctools has also two other tools that help computing variables for Spatial Interaction Models (SIM):

gw_variable: the calculation of the regional or geographically weighted version of a variable (Fotheringham et al., 2002; 2004)

acc: the calculation of the destination accessibility (or centrality) measure necessary for the Competing Destinations Model in SIM

Download lctools

lctools is available at the Comprehensive R Archive Network (CRAN): https://CRAN.R-project.org/package=lctools. A reference manual for lctools is available here…

References

Cromley, R. G. and Hanink, D. M. (2012), Focal Location Quotients: Specification and Application, Geographical Analysis, 44 (4), pp. 398-410. doi: 10.1111/j.1538-4632.2012.00852.x

Fotheringham, A.S., Barmby, T., Brunsdon, C., Champion, T., Charlton, M., Kalogirou, S., Tremayne, A., Rees, P., Eyre, H., Macgill, J., Stillwell, J., Bramley, G., and Hollis, J., 2002, Development of a Migration Model: Analytical and Practical Enhancements, Office of the Deputy Prime Minister. URL: https://www.academia.edu/5274441/Development_of_a_Migration_Model_Analytical_and_Practical_Enhancements

Fotheringham, A.S., Rees, P., Champion, T., Kalogirou, S., and Tremayne, A.R., 2004, The Development of a Migration Model for England and Wales: Overview and Modelling Out-migration, Environment and Planning A, 36, pp. 1633 – 1672. doi:10.1068/a36136. URL: https://journals.sagepub.com/doi/10.1068/a36136

Kalogirou, S., 2003, The Statistical Analysis And Modelling Of Internal Migration Flows Within England And Wales, PhD Thesis, School of Geography, Politics and Sociology, University of Newcastle upon Tyne, UK. URL:  https://theses.ncl.ac.uk/jspui/handle/10443/204

Kalogirou, S., 2012, Testing local versions of correlation coefficients, Review of Regional Research – Jahrbuch fur Regionalwissenschaft, 32, 1, pp. 45 – 61, doi: 10.1007/s10037-011-0061-y. Url: https://link.springer.com/article/10.1007/s10037-011-0061-y

Kalogirou, S., 2013, Testing geographically weighted multicollinearity diagnostics, GISRUK 2013, Department of Geography and Planning, School of Environmental Sciences, University of Liverpool, Liverpool, UK, 3-5 April 2013.

Kalogirou, S. (2015) Spatial Analysis: Methodology and Applications with R. [ebook] Athens: Hellenic Academic Libraries Link. ISBN: 978-960-603-285-1 (in Greek). https://repository.kallipos.gr/handle/11419/5029?locale=en

Kalogirou, S. (2016) Destination Choice of Athenians: an application of geographically weighted versions of standard and zero inflated Poisson spatial interaction models, Geographical Analysis, 48(2),pp. 191-230. DOI: 10.1111/gean.12092

Rey, S.J., Smith J.S., 2013, A spatial decomposition of the Gini coefficient, Letters in Spatial and Resource Sciences, 6 (2), pp. 55-70.