{"id":21299,"library":"esda","title":"esda: Exploratory Spatial Data Analysis in PySAL","description":"esda is a Python library implementing methods for exploratory spatial data analysis, part of the PySAL family. It provides global and local spatial autocorrelation statistics (Moran's I, Geary's C, Getis-Ord G, etc.), spatial correlograms, and shape-based measures. Current version is 2.9.0, requires Python >=3.11. Releases follow a monthly-to-quarterly cadence, with active maintenance.","status":"active","version":"2.9.0","language":"python","source_language":"en","source_url":"https://github.com/pysal/esda","tags":["spatial-analysis","geospatial","pysal","moran-i","spatial-autocorrelation","esda"],"install":[{"cmd":"pip install esda","lang":"bash","label":"Quick install"},{"cmd":"pip install esda[all]","lang":"bash","label":"Install with full extras (e.g., plotting)"}],"dependencies":[{"reason":"Provides spatial weights (W) and core spatial data structures.","package":"libpysal","optional":false},{"reason":"Used for statistical distributions and randomizations.","package":"scipy","optional":false},{"reason":"Core array operations.","package":"numpy","optional":false},{"reason":"Required for geometric operations in shape and map_comparison modules.","package":"shapely","optional":true},{"reason":"Used for data handling in some utilities.","package":"pandas","optional":true}],"imports":[{"note":null,"wrong":null,"symbol":"Moran","correct":"from esda import Moran"},{"note":"Moran_Local is directly importable from esda since v2.0.","wrong":"from esda.moran import Moran_Local","symbol":"Moran_Local","correct":"from esda import Moran_Local"},{"note":null,"wrong":null,"symbol":"Geary","correct":"from esda import Geary"},{"note":null,"wrong":null,"symbol":"Getis_Ord_G","correct":"from esda import Getis_Ord_G"}],"quickstart":{"code":"import libpysal\nfrom esda import Moran\nimport numpy as np\n\n# Generate random data and a spatial weights matrix\nnp.random.seed(123)\ny = np.random.random(100)\nw = libpysal.weights.KNN(k=5, ids=np.arange(100))\n\n# Compute Global Moran's I\nmi = Moran(y, w)\nprint(f\"Moran's I: {mi.I:.3f}, p-value: {mi.p_sim:.3f}\")\n# Output: Moran's I: -0.022, p-value: 0.632","lang":"python","description":"Compute Global Moran's I with a K-nearest neighbors weight matrix."},"warnings":[{"fix":"pip install shapely>=2 or ensure you have a compatible version.","message":"In esda>=2.5, shapely>=2 is required and pygeos is no longer supported. Upgrade shapely or pin shapely<2.","severity":"breaking","affected_versions":">=2.5.0"},{"fix":"moran_local = Moran_Local(y, w, permutations=0)","message":"Moran_Local (Local Moran's I) uses a randomization-based p-value by default. For analytical p-values, set `permutations=0` when constructing the object.","severity":"gotcha","affected_versions":"all"},{"fix":"import libpysal; lag = libpysal.weights.lag_spatial(w, y)","message":"The `spatial_lag` function is not a separate function; use `libpysal.weights.lag_spatial(w, y)` instead.","severity":"gotcha","affected_versions":"all"},{"fix":"from esda.rate_smoothing import assuncao_rate","message":"The `assuncao_rate` function is deprecated since version 2.5. Please use `esda.rate_smoothing.assuncao_rate` instead.","severity":"deprecated","affected_versions":">=2.5.0"},{"fix":"pip install matplotlib","message":"When using `Moran_Local.plot()` or `Moran_Local.scatterplot()`, ensure matplotlib is installed. These are available since v2.7.","severity":"gotcha","affected_versions":">=2.7.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from esda import Moran_Local` instead of `from esda.moran import Moran_Local`.","cause":"Trying to import Moran_Local from the wrong submodule.","error":"ModuleNotFoundError: No module named 'esda.moran'"},{"fix":"Use `w.transform = 'R'` before passing to Moran, or create weights with row-standardization (e.g., `libpysal.weights.KNN(..., transform='R')`).","cause":"Moran class expects row-standardized weights by default.","error":"ValueError: The weights matrix is not row-standardized."},{"fix":"Ensure `y` is a 1D numeric array and `w` is a properly initialized libpysal weights object.","cause":"The object was not created correctly; perhaps `y` is not numeric or `w` is invalid.","error":"AttributeError: 'Moran' object has no attribute 'I'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}