Skip to main content

Spatialize: A Python/C++ library for Ensemble Spatial Analysis (ESA)

An open source library for spatial analysis that combines the simplicity of basic methods with the power of geostatistical tools.

Overview

Spatialize implements Ensemble Spatial Analysis (ESA), which encompasses two complementary approaches: Ensemble Spatial Interpolation (ESI) and Ensemble Spatial Simulation (ESS). These novel methods address the limitations of traditional geostatistical approaches by leveraging ensemble learning techniques.

ESI works by generating multiple estimates for each target location by creating different spatial partitions of the sample data and applying an interpolation algorithm within each local subset. These local estimates are then aggregated to produce robust predictions. ESS extends this framework to provide stochastic simulation capabilities.

Designed to bridge the gap between expert and non-expert users of geostatistics, Spatialize provides automated tools that eliminate the need for manual spatial analysis and extensive domain expertise.

Main features:

  • Automated Spatial Estimation: Minimal user intervention required
  • Stochastic Modelling & Ensemble Learning: Robust, scalable and suitable for large datasets
  • Uncertainty Quantification: Provides both point estimates and empirical posterior distributions
  • Flexible Data Support: Works with both gridded and non-gridded data
  • Hyperparameter Optimization: Built-in grid search with cross-validation
  • High Performance: C++ core with Python interface

Installation

The source code is currently hosted on GitHub at: https://github.com/alges/spatialize

Direct installers for the latest released version are available at the Python Package Index (PyPI).

PyPI

pip install spatialize

System Requirements

  • Python 3.8+
  • Compatible with Linux, macOS, and Windows

Dependencies

Core Concepts

Function Description
esi_griddata() Spatial interpolation for points on a regular grid
esi_nongriddata() Spatial interpolation for scattered points
esi_hparams_search() Automated hyperparameter optimization with cross-validation

Local Interpolators

  • IDW (Inverse Distance Weighting): Simple yet powerful with configurable distance exponent
  • Kriging: Geostatistical method with multiple variogram models (spherical, exponential, cubic and gaussian)

Partition Methods

  • Mondrian Forests: Uses recursive, axis-aligned partitions (supports up to 5D)
  • Voronoi Forests: Uses Voronoi diagram-based partitions (supports up to 2D)

Quick Start

Here are a few examples to get you started.

Basic Gridded Data Estimation

import numpy as np
from spatialize.gs.esi import esi_griddata

# Generate sample data
def func(x, y):		# a kind of "cubic" function
    return x * (1 - x) * np.cos(4 * np.pi * x) * np.sin(4 * np.pi * y ** 2) ** 2

points = np.random.random((100, 2))
values = func(points[:, 0], points[:, 1])

# Define the estimation grid
grid_x, grid_y = np.mgrid[0:1:50j, 0:1:50j]

# Perform ESI estimation
result = esi_griddata(points, values, (grid_x, grid_y),
		      local_interpolator="idw",
		      p_process="mondrian",
		      n_partitions=300,
		      alpha=0.8,
		      exponent=1.0
		      )

# Get results
estimation = result.estimation()
precision = result.precision()

# Quick visualization
result.quick_plot()

Non-gridded Data Estimation

from spatialize.gs.esi import esi_nongriddata

# Define target locations
target_points = np.random.random((50, 2))

# Perform estimation, using Kriging as local interpolator
result = esi_nongriddata(points, values, target_points,
		         local_interpolator="kriging",
		         model="spherical",
		         nugget=0.1,
		         range=10.0,
		         sill=1.0
		         )

Automated Hyperparameter Search

from spatialize.gs.esi import esi_hparams_search

# Search for optimal parameters
search_result = esi_hparams_search(points, values, (grid_x, grid_y),
			           local_interpolator="idw",
			           griddata=True,
			           k=10,
			           exponent=[1.0, 2.0, 3.0, 4.0],
			           alpha=[0.7, 0.8, 0.9],
			           n_partitions=[100, 300, 500]
			           )

# Perform estimation using best parameters found
best_result = esi_griddata(points, values, (grid_x, grid_y),
			   local_interpolator="idw",
			   best_params_found=search_result.best_result()
			   )

# Visualize search results
search_result.plot_cv_error()

License

Apache-2.0

Citing Spatialize

Please refer to the following articles when publishing work relating to this library or the ESI model:

@article{
	title = {Spatial distributional estimation via ensemble spatial analysis},
	journal = {AIMS Mathematics},
	volume = {10},
	number = {11},
	pages = {26351-26388},
	year = {2025},
	issn = {2473-6988},
	doi = {10.3934/math.20251159},
	url = {https://www.aimspress.com/article/doi/10.3934/math.20251159},
	author = {Alvaro F. Ega{\~n}a and Gonzalo D{\'i}az and Felipe Navarro and Mohammad Maleki and Juan F. S{\'a}nchez-P{\'e}rez},
	keywords = {geostatistics, computational geostatistics, generative geostatistics, non-linear geostatistics, distributional geostatistics, geostatistical simulation, empirical copula, data-driven methods},
	}

@article{spatialize2025,
	author  = {Navarro, Felipe and Ega{\~n}a, {\'A}lvaro F. and Ehrenfeld, Alejandro and Garrido, Felipe and Valenzuela, Mar{\'i}a Jes{\'u}s and S{\'a}nchez-P{\'e}rez, Juan F. },
	title   = {Spatialize v1.0: A Python/C++ Library for Ensemble Spatial Interpolation},
	journal = {},
	year    = {2025},
	volume  = {},
	number  = {},
	pages   = {},
	doi     = {https://doi.org/10.48550/arXiv.2507.17867},
	url     = {https://arxiv.org/abs/2507.17867},
	issn    = {}
	}

@article{AdaptiveESI2025,
	author  = {Ega{\~n}a, {\'A}lvaro F. and Valenzuela, María Jesús and Maleki, Mohammad and S{\'a}nchez-P{\'e}rez, Juan F. and Díaz, Gonzalo},
	title   = {Adaptive ensemble spatial analysis},
	journal = {Scientific Reports},
	year    = {2025},
	volume  = {15},
	number  = {1},
	pages   = {26599},
	doi     = {10.1038/s41598-025-08844-z},
	url     = {https://doi.org/10.1038/s41598-025-08844-z},
	issn    = {2045-2322}
	}

@article{ESI2021,
	author  = {Ega{\~n}a, {\'A}lvaro F. and Navarro, Felipe and Maleki, Mohammad and Grand{\'o}n, Francisca and Carter, Francisco and Soto, Fabi{\'a}n},
	title   = {Ensemble Spatial Interpolation: A New Approach to Natural or Anthropogenic Variable Assessment},
	journal = {Natural Resources Research},
	volume  = {30},
	number  = {5},
	pages   = {3777--3793},
	year    = {2021},
	doi     = {https://doi.org/10.1007/s11053-021-09860-2},
	url     = {https://link.springer.com/article/10.1007/s11053-021-09860-2}
	}

Release files for spatialize 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spatialize 1.1.2
File Size Uploaded
spatialize-1.1.2.tar.gz 49.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for spatialize 1.1.2
File
spatialize-1.1.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
spatialize-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
spatialize-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
spatialize-1.1.2-cp313-cp313-macosx_10_13_universal2.whl CPython 3.13 CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) Details

Total release size: 249.9 MB

Release files / spatialize-1.1.2.tar.gz

Download URL spatialize-1.1.2.tar.gz
Size 49.9 MB
Tags Source
SHA-256 checksum
How to use checksums
e4ee9f0b93ed55c1e31bd5b782c8d0ceb7b43ebaf61cdd280f1a8ff9b9940b62
BLAKE2b-256 checksum
How to use checksums
2718121f569072d80b8e6eeedd1c6fa790af6dbd21416a4434d9491bf991aa31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / spatialize-1.1.2-cp313-cp313-win_amd64.whl

Download URL spatialize-1.1.2-cp313-cp313-win_amd64.whl
Size 49.5 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
4feace05dcad70e76afce3234b82e650052a0be142ef8a812fa8a611694e2b0d
BLAKE2b-256 checksum
How to use checksums
ce43d63eff872b7286b3ea9985e728bae2dd40c16de2e875faecdffb4340b2aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / spatialize-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL spatialize-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Size 50.8 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
ce3a4f8b789cd7d21405a5da56ce1fb6eb3074e4fdaa1e2cdb2a4da3ea73facb
BLAKE2b-256 checksum
How to use checksums
4530ec628995bc28a8aa6c1078047553d5a9008f08438f7a1be25f428c34d05d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / spatialize-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL spatialize-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 49.7 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7ead11ef74e4b88ad4bed15e3e97ed6ca173313ff3c8cab791785c04a310e48b
BLAKE2b-256 checksum
How to use checksums
26bce6ff6c9837e512c9530c306e005e9132d573f9872e6ef5fe60b2cc60b3f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / spatialize-1.1.2-cp313-cp313-macosx_10_13_universal2.whl

Download URL spatialize-1.1.2-cp313-cp313-macosx_10_13_universal2.whl
Size 50.0 MB
Tags CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
93784035d454ff679d3343c46dc8ea778aa04c9eaafdfcb2b4742f35be1e450e
BLAKE2b-256 checksum
How to use checksums
ee3ad052223c894169696f196b9b134b16778f7311c57331f9565fd75ab6f4a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.0

5 release files

This release

1.1.2 This release

5 release files

1.1.1

5 release files

1.1.0

5 release files

1.0.2

2 release files

1.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page