Collection of geospatial algorithms, parallel computation utilities and project management tools.
Project description
Hazelbean
Hazelbean is a collection of geospatial processing tools based on gdal, numpy, scipy, cython, pygeoprocessing, taskgraph, natcap.invest, geopandas and many others to assist in common spatial analysis tasks in sustainability science, ecosystem service assessment, global integrated modelling assessment, natural capital accounting, and/or calculable general equilibrium modelling.
Requirements
- Python 3.10 or later (Python 3.9 support was dropped as of version 14.0.0 due to NumPy 2.0 compatibility issues)
Hazelbean started as a personal research package of scripts for Justin Johnson and is was not originally intended for broad release. However, hazelbean is transitioning towards having full-support, primarily because it underlies several important software releases, including some from the Natural Capital Project. Thus, even in this transitory state, it is available via "pip install hazelbean". Note that hazelbean only provides a Python 3+, 64 bit, Windows version, however with the exception of precompiled cython files, it should be cross-platform and cross-version. The precompiled files are only loaded as needed.
📚 Documentation
Our integrated documentation system provides comprehensive guides and examples:
- 📝 Getting Started - Complete setup guide with current project structure
- 📚 Testing Guide - Test infrastructure overview
- 🎓 Examples - Hands-on tutorials and demonstrations
Local Documentation Site
You can serve the full documentation site locally with searchable content, test examples, and live reports:
conda activate hazelbean_env
cd docs-site
mkdocs serve # Visit http://127.0.0.1:8000
The local site includes: - Progressive learning path with tutorials - 50+ test examples showing real-world usage patterns - Current test results and performance metrics - Searchable content across all documentation
⚡ Quick Start (5 minutes)
Option 1: Complete Environment (Recommended)
# 1. Clone repository and setup complete environment
git clone https://github.com/jandrewjohnson/hazelbean_dev.git
cd hazelbean_dev
# 2. Create environment from included configuration
mamba env create -f environment.yml
mamba activate hazelbean_env
# 3. Install hazelbean package (builds Cython extensions)
pip install -e . --no-deps
# 4. Test installation
python -c "import hazelbean as hb; print('✅ Hazelbean ready!')"
# 5. Try educational examples
cd examples && python step_1_project_setup.py
# 6. Explore documentation locally
cd docs-site && mkdocs serve # Visit http://127.0.0.1:8000
Note: The pip install -e . --no-deps command installs hazelbean in editable mode and compiles the Cython extensions. The --no-deps flag prevents pip from reinstalling conda packages, which is the correct approach for conda+pip hybrid environments.
Option 2: Package Only
# Basic installation for using Hazelbean in existing environment
mamba install -c conda-forge natcap.invest geopandas pygeoprocessing taskgraph cython
pip install hazelbean
Next steps: Explore the examples/ directory for guided learning.
Detailed Installation Notes
Prerequisites
- Install Mambaforge from https://github.com/conda-forge/miniforge#mambaforge
- For convenience, during installation, select "Add Mambaforge to my PATH environment Variable"
Troubleshooting
Numpy Compatibility Issues: If numpy throws "wrong size or changes size binary" errors, upgrade numpy after installation:
mamba update numpy
macOS Permissions: Your Python environment needs permissions to access and write to the base data folder. Grant necessary permissions in System Preferences if needed.
More information
See the author's personal webpage, https://justinandrewjohnson.com/ for more details about the underlying research.
Project Flow
One key component of Hazelbean is that it manages directories, base_data, etc. using a concept called ProjectFlow. ProjectFlow defines a tree of tasks that can easily be run in parallel where needed and keeping track of task-dependencies. ProjectFlow borrows heavily in concept (though not in code) from the task_graph library produced by Rich Sharp but adds a predefined file structure suited to research and exploration tasks.
Project Flow notes
Project Flow is intended to flow easily into the situation where you have coded a script that grows and grows until you think "oops, I should really make this modular." Thus, it has several modalities useful to researchers ranging from simple drop-in solution to complex scripting framework.
Notes
In run.py, initialize the project flow object. This is the only place where user supplied (possibly absolute but can be relative) path is stated. The p ProjectFlow object is the one global variable used throughout all parts of hazelbean.
import hazelbean as hb
if __name__ == '__main__':
p = hb.ProjectFlow(r'C:\Files\Research\cge\gtap_invest\projects\feedback_policies_and_tipping_points')
In a multi-file setup, in the run.py you will need to import different scripts, such as main.py i.e.:
import visualizations.main
The script file mainpy can have whatever code, but in particular can include "task" functions. A task function, shown below, takes only p as an agrument and returns p (potentially modified). It also must have a conditional (if p.run_this:) to specify what always runs (and is assumed to run trivially fast, i.e., to specify file paths) just by nature of having it in the task tree and what is run only conditionally (based on the task.run attribute, or optionally based on satisfying a completed function.)
def example_task_function(p):
"""Fast function that creates several tiny geotiffs of gaussian-like kernels for later use in ffn_convolve."""
if p.run_this:
for i in computationally_intensive_loop:
print(i)
Important Non-Obvious Note
Importing the script will define function(s) to add "tasks", which take the ProjectFlow object as an argument and returns it after potential modification.
def add_all_tasks_to_task_tree(p):
p.generated_kernels_task = p.add_task(example_task_function)
Creating a new release
Github Actions will now generate a new set of binaries for each release, upload them to PyPI and then trigger a condaforge build. All you need to do is make and tag the release.
Manually builds to PyPI via Twine
To upload built packages to PyPI, you will need an API key from your PyPI account, and you will need a local install of the twine utility. To install twine, you can use either pip or mamba. For example:
pip install twine
Once you have built the package for your target platform(s), you can upload the file to PyPI with twine via the twine command. For example, if you have all of your target distributions in the dist/ directory, you can upload them all with:
twine upload --username=__token__ --password="$PYPI_API_TOKEN" dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hazelbean-1.8.0.tar.gz.
File metadata
- Download URL: hazelbean-1.8.0.tar.gz
- Upload date:
- Size: 11.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3317461d74510a279af92b3413d0d2ffa7e4508ef9251e840dd27ba5d440352
|
|
| MD5 |
82f64e14f06404142f19e4bdfba62d4a
|
|
| BLAKE2b-256 |
8f0d6f0aaa80114bfd8ea6a85b0246d1ec17916964f349ebec3ebd594dc61576
|
File details
Details for the file hazelbean-1.8.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2617403e53576a3bc32de0e9f1bcc9597e8a0f4449f49cfe29577a7d85c9650
|
|
| MD5 |
01b0afe6674e2877bb853c331d5c0bf0
|
|
| BLAKE2b-256 |
ff7296328e0d5eb668a92b7472eb0511291ea5e75eb5323ae9d33d6c645008b4
|
File details
Details for the file hazelbean-1.8.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cea7cde482e7b3e5c992e27f70485ad7507b3a0c5868cd519e35f26c12d52f3
|
|
| MD5 |
3288297fd1e307d9dd06b2f6aca7fd87
|
|
| BLAKE2b-256 |
3e9b6c4cae838d1fa8eb70a242af734a50ee35f4526ae4e00c1ec17ff1fe5b1c
|
File details
Details for the file hazelbean-1.8.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64afd1493b8a969daa2733df9ff720e92f9be423502222d4857292242b04fc7a
|
|
| MD5 |
8832429c85326f2437a135c3347c28fd
|
|
| BLAKE2b-256 |
0c45631c70238f446359939ca0a134261f12d33032c917db6caa3707784963da
|
File details
Details for the file hazelbean-1.8.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5637b7f2d0d07d74b72e91679258ae32027efc653c2241b84db36608afa9d45f
|
|
| MD5 |
e905049b07bf9dc7b0802f4015dc8a8a
|
|
| BLAKE2b-256 |
64fd6382eac8e416fcba9a11c432f76a4513dc76dbf6902328291a7cd5e569dd
|
File details
Details for the file hazelbean-1.8.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae49a5464cbcf77207721bdaea4c6277d88ed9e9999ade2dcc0a4609a35cf021
|
|
| MD5 |
424f4374a92a5bc98ed474fb39c718b2
|
|
| BLAKE2b-256 |
65f567b0646966dce6cd8aa3879bdcc18908e747c89d85bef1366d332119758d
|
File details
Details for the file hazelbean-1.8.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
843bad94cebb2dabb5b8e8f3ebce508290c7e2f006069c76c88eead1722173c2
|
|
| MD5 |
0864467517708e2c58d492858ce72f3a
|
|
| BLAKE2b-256 |
638a1d6d2dcbf541f36f5074fcec06067f5b1ad80d391946e9d3d2ee5245bb12
|
File details
Details for the file hazelbean-1.8.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65917d2f33872a8c9212403cfc2bc2784ef89cae9801d32e95d71d862ee5328b
|
|
| MD5 |
bcfbad5b595f8a449d22787dcbfb6d99
|
|
| BLAKE2b-256 |
4305d859a5cb5a70db980d6ed30eb170982c4c5aaa0794e2fc3073256b3f19d2
|
File details
Details for the file hazelbean-1.8.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: hazelbean-1.8.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15b62d63f0615e8534bbf0180fd5f4d39e6315868745ec8e5a7b5a518d2c42ea
|
|
| MD5 |
688c3f551885b490cbca61a6edf559ad
|
|
| BLAKE2b-256 |
c7ffba8f147a7d956a0bd261af4855c9ff0874b05be90b6a9bff17ac16d8d8e2
|