rastr 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rastr might be problematic. Click here for more details.
- {rastr-0.2.0 → rastr-0.4.0}/.github/copilot-instructions.md +13 -24
- {rastr-0.2.0 → rastr-0.4.0}/.github/workflows/ci.yml +9 -4
- {rastr-0.2.0 → rastr-0.4.0}/.github/workflows/release.yml +1 -1
- {rastr-0.2.0 → rastr-0.4.0}/.pre-commit-config.yaml +7 -7
- rastr-0.4.0/CONTRIBUTING.md +77 -0
- rastr-0.4.0/PKG-INFO +138 -0
- rastr-0.4.0/README.md +104 -0
- rastr-0.4.0/docs/index.md +3 -0
- rastr-0.4.0/docs/logo.svg +161 -0
- {rastr-0.2.0 → rastr-0.4.0}/pyproject.toml +24 -20
- rastr-0.4.0/pyrightconfig.json +16 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/_version.py +16 -3
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/arr/fill.py +9 -2
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/create.py +155 -35
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/gis/fishnet.py +13 -4
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/gis/smooth.py +7 -4
- rastr-0.4.0/src/rastr/io.py +94 -0
- rastr-0.4.0/src/rastr/meta.py +87 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/raster.py +297 -60
- rastr-0.4.0/src/scripts/demo_point_cloud.py +12 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/install_backend.sh +1 -1
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/gis/test_fishnet.py +16 -2
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/gis/test_smooth.py +4 -2
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/test_create.py +215 -0
- rastr-0.4.0/tests/rastr/test_io.py +197 -0
- rastr-0.4.0/tests/rastr/test_raster.py +1488 -0
- {rastr-0.2.0 → rastr-0.4.0}/uv.lock +71 -2
- rastr-0.2.0/PKG-INFO +0 -44
- rastr-0.2.0/README.md +0 -10
- rastr-0.2.0/docs/index.md +0 -3
- rastr-0.2.0/src/rastr/io.py +0 -29
- rastr-0.2.0/src/rastr/meta.py +0 -50
- rastr-0.2.0/tests/rastr/test_io.py +0 -53
- rastr-0.2.0/tests/rastr/test_raster.py +0 -908
- {rastr-0.2.0 → rastr-0.4.0}/.copier-answers.yml +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/.github/ISSUE_TEMPLATE/enhancement.md +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/.gitignore +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/.python-version +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/LICENSE +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/mkdocs.yml +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/requirements.txt +4 -4
- {rastr-0.2.0 → rastr-0.4.0}/src/archive/.gitkeep +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/notebooks/.gitkeep +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/__init__.py +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/arr/__init__.py +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/rastr/gis/__init__.py +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/src/scripts/.gitkeep +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/ABOUT_TASKS.md +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/dev_sync.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/activate_venv.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/configure_project.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/dev_sync.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/install_venv.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/recover_corrupt_venv.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/sh_runner.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/sync_requirements.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/scripts/sync_template.sh +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/activate_venv +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/activate_venv.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/activate_venv.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/configure_project +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/configure_project.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/configure_project.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/dev_sync +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/dev_sync.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/dev_sync.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_backend +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_backend.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_backend.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_venv +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_venv.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/install_venv.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/recover_corrupt_venv +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/recover_corrupt_venv.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/recover_corrupt_venv.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_requirements +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_requirements.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_requirements.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_template +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_template.cmd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/shims/sync_template.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tasks/sync_template.ps1 +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/assets/.gitkeep +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/assets/pga_g_clipped.grd +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/assets/pga_g_clipped.tif +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/conftest.py +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/.gitkeep +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/regression_test_data/test_plot_raster.png +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/regression_test_data/test_write_raster_to_file.tif +0 -0
- {rastr-0.2.0 → rastr-0.4.0}/tests/rastr/test_meta.py +0 -0
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## General Guidelines
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
- Every time I ask you to fix linter errors and provide the error messages, update the Linter section in `.github/copilot-instructions.md` accordingly. Use concise, oneliner instruction. Ensure your future responses avoid repeating the same errors.
|
|
5
|
+
- Every time you need to fix linter errors and provide the error messages, update the Linter section in `.github/copilot-instructions.md` accordingly. Use concise, oneliner instruction. Ensure your future responses avoid repeating the same errors.
|
|
7
6
|
- Never create notebooks (ipynb files) unless asked explicitly.
|
|
8
7
|
|
|
9
8
|
## Testing
|
|
@@ -11,29 +10,32 @@
|
|
|
11
10
|
- Write unit tests using `pytest` inside `tests/`, structured based on `src/`.
|
|
12
11
|
- Example: `src/x/y/z` → `tests/x/y/test_z.py`
|
|
13
12
|
- Use test fixtures and group tests into classes when appropriate.
|
|
13
|
+
- When testing methods on classes, create nested test classes within the test class associated with the overall tested class (e.g., `TestContour` nested within `TestRasterModel` when testing the `contour` method of `RasterModel`).
|
|
14
14
|
- After modifying a function, run its unit tests using pytest.
|
|
15
15
|
- Run tests in virtual environment: `.\.venv\Scripts\activate; python -m pytest tests/path/to/test_file.py -v`
|
|
16
16
|
|
|
17
17
|
## Python
|
|
18
18
|
|
|
19
19
|
- We use Python 3.12, so ensure that the code is compatible and up to date with this version.
|
|
20
|
-
- When adding a new package that requires installation,
|
|
20
|
+
- When adding a new package that requires installation, add it using `uv add <pkg>` so it gets properly declared.
|
|
21
|
+
- When running a CLI such as `pytest`, always run it using `uv run`, e.g. `uv run pytest`.
|
|
22
|
+
- Always run `uv run pre-commit run --all-files` to determine whether your code is compliant with the pre-commit hooks, including linters.
|
|
23
|
+
- When importing internal modules, do not include the "src" folder in the import path as it is already defined in pyproject.toml
|
|
21
24
|
- Limit line length to 100 characters.
|
|
22
|
-
-
|
|
23
|
-
- Never create functions that return more than one output value.
|
|
24
|
-
- Never return tuples; use dictionaries for multiple return values.
|
|
25
|
+
- Never create functions that return more than one output value (i.e. Never return tuples). Use dedicated return classes.
|
|
25
26
|
- Do not add exceptions to functions unless explicitly requested.
|
|
26
27
|
- Prefer to type hint strictly with the likes of `Literal["a", "b"]` instead of hinting broader types like `str`. This means the constraints on the input arguments to a function can reside in the type annotation rather than the docstring. Consider @validate_call (from pydantic import validate_call) to avoid boilerplate case-checking in such cases.
|
|
28
|
+
- Prefer `isinstance` rather than `hasattr` for runtime type inference.
|
|
27
29
|
- Refrain from backslash unescaping in raw strings (e.g., `r"\\path"` should be `r"\path"`).
|
|
28
30
|
- When writing scripts, always use "Scripting Style" (Top-Level Code) unless stated otherwise. Write code directly at the module level instead of wrapping in functions or `if __name__ == "__main__":` blocks.
|
|
29
31
|
- For scripts that need to access package files (e.g., templates, data files):
|
|
30
32
|
|
|
31
33
|
```python
|
|
32
34
|
from importlib.resources import files
|
|
33
|
-
|
|
35
|
+
|
|
34
36
|
# Define package path as a module-level constant
|
|
35
37
|
PACKAGE_PATH = files('package.subpackage.module')
|
|
36
|
-
|
|
38
|
+
|
|
37
39
|
# Use joinpath for accessing files
|
|
38
40
|
file_path = Path(str(PACKAGE_PATH.joinpath('filename')))
|
|
39
41
|
```
|
|
@@ -45,23 +47,12 @@
|
|
|
45
47
|
- Remove dtype specifications from all `Args:` sections (e.g., `text (str):` → `text:`)
|
|
46
48
|
- Use "Args:" instead of "Parameters:" for consistency
|
|
47
49
|
|
|
48
|
-
## Code Structure & Data Handling
|
|
49
|
-
|
|
50
|
-
- Use value objects stored in `src/<package_name>/domain/value_object.py`, implemented using Pandera > v0.2 and Pydantic. Prefer passing DataFrame when possible.
|
|
51
|
-
- Use Pandera > v0.2 syntax, such as `DataFrameModel` when possible.
|
|
52
|
-
- When importing internal modules, do not include the "src" folder in the import path as it is already defined in pyproject.toml
|
|
53
|
-
|
|
54
50
|
## Linter
|
|
55
51
|
|
|
56
|
-
- For file-level linter suppressions, use `# ruff: noqa: RULE1, RULE2` format (not `# ruff noqa:`)
|
|
57
|
-
- For line-level suppressions, use `# noqa: RULE1, RULE2` format
|
|
52
|
+
- For file-level linter suppressions, use `# ruff: noqa: RULE1, RULE2` format (not `# ruff noqa:`). Avoid these where possible.
|
|
58
53
|
- Use `pathlib.Path` for all filesystem operations instead of `os.path`. Path objects provide a more readable and maintainable object-oriented interface (e.g., `Path('dir') / 'file.txt'` instead of `os.path.join()`, `path.exists()` instead of `os.path.exists()`, etc.)
|
|
59
|
-
- Exception messages must not use string literals directly, assign to variables first
|
|
60
|
-
- Try-except patterns: Use bare `raise` in except blocks to preserve the original traceback, put return statements in the `else` block when using try-except (e.g., `try: result = process() except Exception: raise else: return result`)
|
|
61
54
|
- Remove trailing whitespace from blank lines (W293)
|
|
62
55
|
- Move statements after try blocks into else blocks when the statements depend on the try block's success (TRY300)
|
|
63
|
-
- Use logging.exception instead of logging.error in except blocks (TRY400)
|
|
64
|
-
- Do not include the exception object in logging.exception calls (TRY401)
|
|
65
56
|
- Use keyword arguments for boolean parameters (FBT003) instead of positional arguments
|
|
66
57
|
- Make boolean default arguments keyword-only using `*` to prevent positional passing (FBT002)
|
|
67
58
|
- Avoid variable names that shadow Python builtins (A001)
|
|
@@ -70,15 +61,13 @@
|
|
|
70
61
|
- Break long docstring lines at logical points to stay under the 88 character limit (E501)
|
|
71
62
|
- Include a blank line between docstring summary and description (D205)
|
|
72
63
|
- Add type annotations to function signatures (ANN201, ANN204)
|
|
73
|
-
- Add `# noqa: N806` comment for scikit-learn convention of uppercase X in tests
|
|
74
64
|
- Use `dict` instead of `Dict` for type annotation (UP006)
|
|
75
65
|
- Avoid importing deprecated types like `typing.Dict` (UP035)
|
|
76
|
-
-
|
|
77
|
-
- Never use `from __future__ import annotations` in any file; Python 3.11+ does not require it.
|
|
66
|
+
- Use `NDArray` without specific dtype parameter (e.g., `NDArray` instead of `NDArray[np.number]`) for generic array parameters
|
|
78
67
|
|
|
79
68
|
## Testing
|
|
80
69
|
|
|
81
|
-
- Use `pytest` for testing, and ensure all tests are passing before committing changes.
|
|
70
|
+
- Use `uv run pytest` for testing, and ensure all tests are passing before committing changes.
|
|
82
71
|
- Do not perform equality checks with floating point values; instead, use `pytest.approx`.
|
|
83
72
|
- Use only one assert statement per test function to ensure clarity and simplicity.
|
|
84
73
|
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
- name: Set up uv
|
|
37
37
|
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
|
|
38
38
|
with:
|
|
39
|
-
version: "0.
|
|
39
|
+
version: "0.7.13" # Sync with pyproject.toml
|
|
40
40
|
enable-cache: true
|
|
41
41
|
|
|
42
42
|
- name: Set up Python
|
|
@@ -51,10 +51,15 @@ jobs:
|
|
|
51
51
|
uv pip install --system -r ci-requirements.txt
|
|
52
52
|
|
|
53
53
|
- name: Run pre-commit
|
|
54
|
-
if: matrix.
|
|
54
|
+
if: matrix.checks
|
|
55
55
|
run: |
|
|
56
56
|
uv run --frozen pre-commit run --all-files
|
|
57
57
|
|
|
58
|
+
- name: Run pyright
|
|
59
|
+
if: matrix.checks
|
|
60
|
+
run: |
|
|
61
|
+
uv run pyright
|
|
62
|
+
|
|
58
63
|
- name: Run pytest
|
|
59
64
|
uses: pavelzw/pytest-action@510c5e90c360a185039bea56ce8b3e7e51a16507 # v2.2.0
|
|
60
65
|
if: matrix.pytest
|
|
@@ -77,13 +82,13 @@ jobs:
|
|
|
77
82
|
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
78
83
|
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
79
84
|
resolution: ["highest"]
|
|
80
|
-
|
|
85
|
+
checks: [true]
|
|
81
86
|
pytest: [true]
|
|
82
87
|
include:
|
|
83
88
|
- os: "ubuntu-latest"
|
|
84
89
|
python-version: "3.10"
|
|
85
90
|
resolution: "lowest-direct"
|
|
86
|
-
|
|
91
|
+
checks: false
|
|
87
92
|
pytest: true
|
|
88
93
|
|
|
89
94
|
code-analysis:
|
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
- name: Set up uv
|
|
20
20
|
uses: astral-sh/setup-uv@3b9817b1bf26186f03ab8277bab9b827ea5cc254 # v3.2.0
|
|
21
21
|
with:
|
|
22
|
-
version: "0.
|
|
22
|
+
version: "0.7.13" # Sync with pyproject.toml
|
|
23
23
|
|
|
24
24
|
- name: "Set up Python"
|
|
25
25
|
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
|
|
@@ -31,7 +31,7 @@ repos:
|
|
|
31
31
|
entry: uv lock --offline
|
|
32
32
|
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$
|
|
33
33
|
additional_dependencies:
|
|
34
|
-
- uv==0.
|
|
34
|
+
- uv==0.7.13
|
|
35
35
|
language: python
|
|
36
36
|
always_run: true
|
|
37
37
|
pass_filenames: false
|
|
@@ -40,7 +40,7 @@ repos:
|
|
|
40
40
|
entry: uv sync --no-active --offline
|
|
41
41
|
args: [--locked]
|
|
42
42
|
additional_dependencies:
|
|
43
|
-
- uv==0.
|
|
43
|
+
- uv==0.7.13
|
|
44
44
|
language: python
|
|
45
45
|
always_run: true
|
|
46
46
|
pass_filenames: false
|
|
@@ -52,7 +52,7 @@ repos:
|
|
|
52
52
|
entry: uv export --frozen --offline --quiet --no-default-groups
|
|
53
53
|
-o="requirements.txt"
|
|
54
54
|
additional_dependencies:
|
|
55
|
-
- uv==0.
|
|
55
|
+
- uv==0.7.13
|
|
56
56
|
language: python
|
|
57
57
|
pass_filenames: false
|
|
58
58
|
require_serial: true
|
|
@@ -76,7 +76,7 @@ repos:
|
|
|
76
76
|
entry: uv run --frozen --offline ruff format --force-exclude
|
|
77
77
|
types_or: [python, pyi, jupyter]
|
|
78
78
|
additional_dependencies:
|
|
79
|
-
- uv==0.
|
|
79
|
+
- uv==0.7.13
|
|
80
80
|
language: python
|
|
81
81
|
pass_filenames: false
|
|
82
82
|
- id: ruff-check
|
|
@@ -86,7 +86,7 @@ repos:
|
|
|
86
86
|
--ignore "FIX"
|
|
87
87
|
types_or: [python, pyi, jupyter]
|
|
88
88
|
additional_dependencies:
|
|
89
|
-
- uv==0.
|
|
89
|
+
- uv==0.7.13
|
|
90
90
|
language: python
|
|
91
91
|
pass_filenames: false
|
|
92
92
|
|
|
@@ -106,7 +106,7 @@ repos:
|
|
|
106
106
|
name: nbstripout
|
|
107
107
|
entry: uv run --frozen --offline nbstripout
|
|
108
108
|
additional_dependencies:
|
|
109
|
-
- uv==0.
|
|
109
|
+
- uv==0.7.13
|
|
110
110
|
language: python
|
|
111
111
|
files: .*\.(ipynb)$
|
|
112
112
|
exclude: .*\.(example|template|keepoutput|)\.ipynb$
|
|
@@ -117,7 +117,7 @@ repos:
|
|
|
117
117
|
name: deptry
|
|
118
118
|
entry: uv run --frozen --offline deptry src
|
|
119
119
|
additional_dependencies:
|
|
120
|
-
- uv==0.
|
|
120
|
+
- uv==0.7.13
|
|
121
121
|
language: python
|
|
122
122
|
always_run: true
|
|
123
123
|
pass_filenames: false
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Rastr!
|
|
4
|
+
|
|
5
|
+
Since `rastr` is at early stages of development, please [ensure a GitHub Issue is opened](https://github.com/tonkintaylor/rastr/issues) before starting work on a new feature or bug fix. This helps to ensure that the feature is aligned with the project's goals and that there is no duplication of effort. Sometimes these Issues don't have enough guidance in them, so consider asking for some more guidance from the ticket creator before getting started.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Most of the setup described below is automated. Try invoking the `tasks/dev_setup` command.
|
|
10
|
+
|
|
11
|
+
### Development Environment
|
|
12
|
+
|
|
13
|
+
[uv](https://github.com/astral-sh/uv) is required to install the development environment. You can install it using the instructions here:
|
|
14
|
+
|
|
15
|
+
<https://docs.astral.sh/uv/getting-started/installation/>
|
|
16
|
+
|
|
17
|
+
Then with the current working directory set to the project root, run:
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
uv sync
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Pre-commit Hooks
|
|
24
|
+
|
|
25
|
+
This project uses the `pre-commit` framework to manage Git hooks. To install the hooks,
|
|
26
|
+
run:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
uv run pre-commit install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Testing
|
|
33
|
+
|
|
34
|
+
### Running the Test Suite
|
|
35
|
+
|
|
36
|
+
To run the tests, simply run:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
uv run pytest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Writing Tests
|
|
43
|
+
|
|
44
|
+
Tests are written using the `pytest` framework. The test suite is located in the `tests` directory. The tests are organized into subdirectories with a directory structure that mirrors the structure of the code being tested. This makes it easy to find the tests for a specific module or function.
|
|
45
|
+
|
|
46
|
+
PRs should ideally include tests for any new features or bug fixes.
|
|
47
|
+
|
|
48
|
+
### Fuzzing Test Leakage (a.k.a. Test Pollution)
|
|
49
|
+
|
|
50
|
+
To diagnose test leakage, run this command:
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
uv run detect-test-pollution --fuzz --tests ./tests
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
and follow the prompts to bisect the tests.
|
|
57
|
+
|
|
58
|
+
### Profiling Test collection speed
|
|
59
|
+
|
|
60
|
+
To profile the speed of test collection (which is mostly related to import times), use `pyinstrument`:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
uv run pyinstrument -m pytest --collect-only
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Version Control
|
|
67
|
+
|
|
68
|
+
Git is used for version control, using
|
|
69
|
+
[Trunk-based development](https://trunkbaseddevelopment.com/).
|
|
70
|
+
|
|
71
|
+
It is recommended that you use signed commits, although this is not a requirement. Please see this guide from the VS Code project for instructions on how to do this: <https://github.com/microsoft/vscode/wiki/Commit-Signing>
|
|
72
|
+
|
|
73
|
+
## Architecture
|
|
74
|
+
|
|
75
|
+
This project uses [Import Linter](https://import-linter.readthedocs.io/en/stable/) to
|
|
76
|
+
enforce a software architecture. Refer to the `[[tool.importlinter.contracts]]` sections
|
|
77
|
+
in `pyproject.toml` to understand the structure of the project.
|
rastr-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rastr
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Geospatial Raster datatype library for Python.
|
|
5
|
+
Project-URL: Source Code, https://github.com/tonkintaylor/rastr
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/tonkintaylor/rastr/issues
|
|
7
|
+
Project-URL: Releases, https://github.com/tonkintaylor/rastr/releases
|
|
8
|
+
Project-URL: Source Archive, https://github.com/tonkintaylor/rastr/archive/336916af169603534dd0728c10401667f263d98a.zip
|
|
9
|
+
Author-email: Tonkin & Taylor Limited <Sub-DisciplineData+AnalyticsStaff@tonkintaylor.co.nz>, Nathan McDougall <nmcdougall@tonkintaylor.co.nz>, Ben Karl <bkarl@tonkintaylor.co.nz>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: affine>=2.4.0
|
|
19
|
+
Requires-Dist: branca>=0.8.1
|
|
20
|
+
Requires-Dist: folium>=0.20.0
|
|
21
|
+
Requires-Dist: geopandas>=1.1.1
|
|
22
|
+
Requires-Dist: matplotlib>=3.10.5
|
|
23
|
+
Requires-Dist: numpy>=2.2.6
|
|
24
|
+
Requires-Dist: pandas>=2.3.1
|
|
25
|
+
Requires-Dist: pydantic>=2.11.7
|
|
26
|
+
Requires-Dist: pyproj>=3.7.1
|
|
27
|
+
Requires-Dist: rasterio>=1.4.3
|
|
28
|
+
Requires-Dist: scikit-image>=0.25.2
|
|
29
|
+
Requires-Dist: scipy>=1.15.3
|
|
30
|
+
Requires-Dist: shapely>=2.1.1
|
|
31
|
+
Requires-Dist: tqdm>=4.67.1
|
|
32
|
+
Requires-Dist: typing-extensions>=4.14.1
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
<h1 align="center">
|
|
36
|
+
<img src="https://raw.githubusercontent.com/tonkintaylor/rastr/refs/heads/develop/docs/logo.svg"><br>
|
|
37
|
+
</h1>
|
|
38
|
+
|
|
39
|
+
# rastr
|
|
40
|
+
|
|
41
|
+
[](<https://pypi.python.org/pypi/rastr>)
|
|
42
|
+
[](https://github.com/astral-sh/uv)
|
|
43
|
+
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
[](https://github.com/usethis-python/usethis-python)
|
|
45
|
+
|
|
46
|
+
A lightweight geospatial raster datatype library for Python focused on simplicity.
|
|
47
|
+
|
|
48
|
+
## Overview
|
|
49
|
+
|
|
50
|
+
`rastr` provides an intuitive interface for creating, reading, manipulating, and exporting geospatial raster data in Python.
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
- 🧮 **Complete raster arithmetic**: Full support for mathematical operations (`+`, `-`, `*`, `/`) between rasters and scalars.
|
|
55
|
+
- 📊 **Flexible visualization**: Built-in plotting with matplotlib and interactive mapping with folium.
|
|
56
|
+
- 🗺️ **Geospatial analysis tools**: Contour generation, Gaussian blurring, and spatial sampling.
|
|
57
|
+
- 🛠️ **Data manipulation**: Fill NaN values, extrapolate missing data, and resample to different resolutions.
|
|
58
|
+
- 🔗 **Seamless integration**: Works with GeoPandas, rasterio, and the broader Python geospatial ecosystem.
|
|
59
|
+
- ↔️ **Vector-to-raster workflows**: Convert GeoDataFrame polygons, points, and lines to raster format.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# With uv
|
|
65
|
+
uv add rastr
|
|
66
|
+
|
|
67
|
+
# With pip
|
|
68
|
+
pip install rastr
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from pyproj.crs.crs import CRS
|
|
75
|
+
from rasterio.transform import from_origin
|
|
76
|
+
from rastr.create import full_raster
|
|
77
|
+
from rastr.meta import RasterMeta
|
|
78
|
+
from rastr.raster import RasterModel
|
|
79
|
+
|
|
80
|
+
# Create an example raster
|
|
81
|
+
raster = RasterModel.example()
|
|
82
|
+
|
|
83
|
+
# Basic arithmetic operations
|
|
84
|
+
doubled = raster * 2
|
|
85
|
+
summed = raster + 10
|
|
86
|
+
combined = raster + doubled
|
|
87
|
+
|
|
88
|
+
# Create full rasters with specified values
|
|
89
|
+
cell_size = 1.0
|
|
90
|
+
empty_raster = full_raster(
|
|
91
|
+
RasterMeta(
|
|
92
|
+
cell_size=cell_size,
|
|
93
|
+
crs=CRS.from_epsg(2193),
|
|
94
|
+
transform=from_origin(0, 100, cell_size, cell_size),
|
|
95
|
+
),
|
|
96
|
+
bounds=(0, 0, 100, 100),
|
|
97
|
+
fill_value=0.0,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Visualize the data
|
|
101
|
+
ax = raster.plot(cbar_label="Values")
|
|
102
|
+
|
|
103
|
+
# Interactive web mapping (requires folium)
|
|
104
|
+
m = raster.explore(opacity=0.8, colormap="plasma")
|
|
105
|
+
|
|
106
|
+
# Sample values at specific coordinates
|
|
107
|
+
xy_points = [(100.0, 200.0), (150.0, 250.0)]
|
|
108
|
+
values = raster.sample(xy_points)
|
|
109
|
+
|
|
110
|
+
# Generate contour lines
|
|
111
|
+
contours = raster.contour(levels=[0.1, 0.5, 0.9], smoothing=True)
|
|
112
|
+
|
|
113
|
+
# Apply spatial operations
|
|
114
|
+
blurred = raster.blur(sigma=2.0) # Gaussian blur
|
|
115
|
+
filled = raster.extrapolate(method="nearest") # Fill NaN values via nearest-neighbours
|
|
116
|
+
resampled = raster.resample(new_cell_size=0.5) # Change resolution
|
|
117
|
+
|
|
118
|
+
# Export to file
|
|
119
|
+
raster.to_file("output.tif")
|
|
120
|
+
|
|
121
|
+
# Convert to GeoDataFrame for vector analysis
|
|
122
|
+
gdf = raster.as_geodataframe(name="elevation")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Limitations
|
|
126
|
+
|
|
127
|
+
Current version limitations:
|
|
128
|
+
|
|
129
|
+
- Only Single-band rasters are supported.
|
|
130
|
+
- In-memory processing only (streaming support planned).
|
|
131
|
+
- Square cells only (rectangular cell support planned).
|
|
132
|
+
- Only float dtypes (integer support planned).
|
|
133
|
+
|
|
134
|
+
### Contributing
|
|
135
|
+
|
|
136
|
+
See the
|
|
137
|
+
[CONTRIBUTING.md](https://github.com/usethis-python/usethis-python/blob/main/CONTRIBUTING.md)
|
|
138
|
+
file.
|
rastr-0.4.0/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/tonkintaylor/rastr/refs/heads/develop/docs/logo.svg"><br>
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
# rastr
|
|
6
|
+
|
|
7
|
+
[](<https://pypi.python.org/pypi/rastr>)
|
|
8
|
+
[](https://github.com/astral-sh/uv)
|
|
9
|
+
[](https://github.com/astral-sh/ruff)
|
|
10
|
+
[](https://github.com/usethis-python/usethis-python)
|
|
11
|
+
|
|
12
|
+
A lightweight geospatial raster datatype library for Python focused on simplicity.
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
`rastr` provides an intuitive interface for creating, reading, manipulating, and exporting geospatial raster data in Python.
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- 🧮 **Complete raster arithmetic**: Full support for mathematical operations (`+`, `-`, `*`, `/`) between rasters and scalars.
|
|
21
|
+
- 📊 **Flexible visualization**: Built-in plotting with matplotlib and interactive mapping with folium.
|
|
22
|
+
- 🗺️ **Geospatial analysis tools**: Contour generation, Gaussian blurring, and spatial sampling.
|
|
23
|
+
- 🛠️ **Data manipulation**: Fill NaN values, extrapolate missing data, and resample to different resolutions.
|
|
24
|
+
- 🔗 **Seamless integration**: Works with GeoPandas, rasterio, and the broader Python geospatial ecosystem.
|
|
25
|
+
- ↔️ **Vector-to-raster workflows**: Convert GeoDataFrame polygons, points, and lines to raster format.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# With uv
|
|
31
|
+
uv add rastr
|
|
32
|
+
|
|
33
|
+
# With pip
|
|
34
|
+
pip install rastr
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from pyproj.crs.crs import CRS
|
|
41
|
+
from rasterio.transform import from_origin
|
|
42
|
+
from rastr.create import full_raster
|
|
43
|
+
from rastr.meta import RasterMeta
|
|
44
|
+
from rastr.raster import RasterModel
|
|
45
|
+
|
|
46
|
+
# Create an example raster
|
|
47
|
+
raster = RasterModel.example()
|
|
48
|
+
|
|
49
|
+
# Basic arithmetic operations
|
|
50
|
+
doubled = raster * 2
|
|
51
|
+
summed = raster + 10
|
|
52
|
+
combined = raster + doubled
|
|
53
|
+
|
|
54
|
+
# Create full rasters with specified values
|
|
55
|
+
cell_size = 1.0
|
|
56
|
+
empty_raster = full_raster(
|
|
57
|
+
RasterMeta(
|
|
58
|
+
cell_size=cell_size,
|
|
59
|
+
crs=CRS.from_epsg(2193),
|
|
60
|
+
transform=from_origin(0, 100, cell_size, cell_size),
|
|
61
|
+
),
|
|
62
|
+
bounds=(0, 0, 100, 100),
|
|
63
|
+
fill_value=0.0,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Visualize the data
|
|
67
|
+
ax = raster.plot(cbar_label="Values")
|
|
68
|
+
|
|
69
|
+
# Interactive web mapping (requires folium)
|
|
70
|
+
m = raster.explore(opacity=0.8, colormap="plasma")
|
|
71
|
+
|
|
72
|
+
# Sample values at specific coordinates
|
|
73
|
+
xy_points = [(100.0, 200.0), (150.0, 250.0)]
|
|
74
|
+
values = raster.sample(xy_points)
|
|
75
|
+
|
|
76
|
+
# Generate contour lines
|
|
77
|
+
contours = raster.contour(levels=[0.1, 0.5, 0.9], smoothing=True)
|
|
78
|
+
|
|
79
|
+
# Apply spatial operations
|
|
80
|
+
blurred = raster.blur(sigma=2.0) # Gaussian blur
|
|
81
|
+
filled = raster.extrapolate(method="nearest") # Fill NaN values via nearest-neighbours
|
|
82
|
+
resampled = raster.resample(new_cell_size=0.5) # Change resolution
|
|
83
|
+
|
|
84
|
+
# Export to file
|
|
85
|
+
raster.to_file("output.tif")
|
|
86
|
+
|
|
87
|
+
# Convert to GeoDataFrame for vector analysis
|
|
88
|
+
gdf = raster.as_geodataframe(name="elevation")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Limitations
|
|
92
|
+
|
|
93
|
+
Current version limitations:
|
|
94
|
+
|
|
95
|
+
- Only Single-band rasters are supported.
|
|
96
|
+
- In-memory processing only (streaming support planned).
|
|
97
|
+
- Square cells only (rectangular cell support planned).
|
|
98
|
+
- Only float dtypes (integer support planned).
|
|
99
|
+
|
|
100
|
+
### Contributing
|
|
101
|
+
|
|
102
|
+
See the
|
|
103
|
+
[CONTRIBUTING.md](https://github.com/usethis-python/usethis-python/blob/main/CONTRIBUTING.md)
|
|
104
|
+
file.
|