cng-datasets 0.3.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.
- cng_datasets-0.3.0/LICENSE +194 -0
- cng_datasets-0.3.0/PKG-INFO +227 -0
- cng_datasets-0.3.0/README.md +189 -0
- cng_datasets-0.3.0/cng_datasets/__init__.py +13 -0
- cng_datasets-0.3.0/cng_datasets/cli.py +463 -0
- cng_datasets-0.3.0/cng_datasets/hex_checks.py +63 -0
- cng_datasets-0.3.0/cng_datasets/k8s/__init__.py +25 -0
- cng_datasets-0.3.0/cng_datasets/k8s/armada.py +226 -0
- cng_datasets-0.3.0/cng_datasets/k8s/jobs.py +228 -0
- cng_datasets-0.3.0/cng_datasets/k8s/profiles/nrp.yaml +10 -0
- cng_datasets-0.3.0/cng_datasets/k8s/workflows.py +1835 -0
- cng_datasets-0.3.0/cng_datasets/raster/__init__.py +5 -0
- cng_datasets-0.3.0/cng_datasets/raster/cog.py +1817 -0
- cng_datasets-0.3.0/cng_datasets/storage/__init__.py +14 -0
- cng_datasets-0.3.0/cng_datasets/storage/rclone.py +272 -0
- cng_datasets-0.3.0/cng_datasets/storage/s3.py +236 -0
- cng_datasets-0.3.0/cng_datasets/storage/setup_bucket.py +284 -0
- cng_datasets-0.3.0/cng_datasets/vector/__init__.py +6 -0
- cng_datasets-0.3.0/cng_datasets/vector/convert_to_parquet.py +1237 -0
- cng_datasets-0.3.0/cng_datasets/vector/h3_tiling.py +1033 -0
- cng_datasets-0.3.0/cng_datasets/vector/repartition.py +239 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/PKG-INFO +227 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/SOURCES.txt +35 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/dependency_links.txt +1 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/entry_points.txt +3 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/requires.txt +30 -0
- cng_datasets-0.3.0/cng_datasets.egg-info/top_level.txt +1 -0
- cng_datasets-0.3.0/pyproject.toml +86 -0
- cng_datasets-0.3.0/setup.cfg +4 -0
- cng_datasets-0.3.0/tests/test_armada.py +395 -0
- cng_datasets-0.3.0/tests/test_cli.py +213 -0
- cng_datasets-0.3.0/tests/test_convert_to_parquet.py +1504 -0
- cng_datasets-0.3.0/tests/test_hex_checks.py +88 -0
- cng_datasets-0.3.0/tests/test_k8s_workflows.py +1298 -0
- cng_datasets-0.3.0/tests/test_raster.py +1665 -0
- cng_datasets-0.3.0/tests/test_storage.py +88 -0
- cng_datasets-0.3.0/tests/test_vector.py +1602 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting the License. You accept and agree to be bound by the
|
|
166
|
+
terms of this License by copying, modifying, or distributing the
|
|
167
|
+
Work (or any work based on the Work).
|
|
168
|
+
|
|
169
|
+
END OF TERMS AND CONDITIONS
|
|
170
|
+
|
|
171
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
172
|
+
|
|
173
|
+
To apply the Apache License to your work, attach the following
|
|
174
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
175
|
+
replaced with your own identifying information. (Don't include
|
|
176
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
177
|
+
comment syntax for the file format. We also recommend that a
|
|
178
|
+
file or class name and description of purpose be included on the
|
|
179
|
+
same "printed page" as the copyright notice for easier
|
|
180
|
+
identification within third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [yyyy] [name of copyright owner]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cng-datasets
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Cloud-native geospatial dataset processing toolkit
|
|
5
|
+
Author-email: Boettiger Lab <cboettig@berkeley.edu>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: duckdb==1.5.4
|
|
11
|
+
Requires-Dist: ibis-framework[duckdb]>=9.0.0
|
|
12
|
+
Requires-Dist: polars>=0.20.0
|
|
13
|
+
Requires-Dist: pyarrow>=15.0.0
|
|
14
|
+
Requires-Dist: geopandas>=0.14.0
|
|
15
|
+
Requires-Dist: rasterio>=1.3.0
|
|
16
|
+
Requires-Dist: numpy<2.0,>=1.20.0
|
|
17
|
+
Requires-Dist: kubernetes>=28.0.0
|
|
18
|
+
Requires-Dist: boto3>=1.34.0
|
|
19
|
+
Requires-Dist: pyyaml>=6.0
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-timeout>=2.2.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
|
|
25
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy>=1.7.0; extra == "dev"
|
|
28
|
+
Provides-Extra: raster
|
|
29
|
+
Requires-Dist: exactextract>=0.2.0; extra == "raster"
|
|
30
|
+
Requires-Dist: rasterio>=1.3.0; extra == "raster"
|
|
31
|
+
Provides-Extra: docs
|
|
32
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
33
|
+
Requires-Dist: furo; extra == "docs"
|
|
34
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
35
|
+
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
36
|
+
Requires-Dist: linkify-it-py; extra == "docs"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# cng-datasets
|
|
40
|
+
|
|
41
|
+
[](https://zenodo.org/badge/latestdoi/921944685)
|
|
42
|
+
|
|
43
|
+
A CLI toolkit for processing large geospatial datasets into cloud-native formats on Kubernetes.
|
|
44
|
+
|
|
45
|
+
**What it does:** Takes source geospatial data (Shapefiles, GeoPackages, FileGDB, GeoTIFFs) and produces:
|
|
46
|
+
|
|
47
|
+
- **GeoParquet** — columnar format for analytical queries (DuckDB, Polars)
|
|
48
|
+
- **PMTiles** — vector tiles for web map visualization
|
|
49
|
+
- **H3 Hex Parquet** — hexagonal grid indexed at configurable H3 resolution, hive-partitioned for fast spatial joins
|
|
50
|
+
- **Cloud-Optimized GeoTIFF** — for raster data, optimized for HTTP range requests
|
|
51
|
+
|
|
52
|
+
**How it works:** You run a single CLI command locally. It generates Kubernetes Job YAML files that orchestrate the entire pipeline on your cluster. You never process data on your local machine — the CLI just generates the jobs.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install cng-datasets
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or from source:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install -e "."
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
### Generate a vector processing pipeline
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cng-datasets workflow \
|
|
72
|
+
--dataset cpad-2024 \
|
|
73
|
+
--source-url https://example.com/cpad.gdb \
|
|
74
|
+
--bucket public-cpad \
|
|
75
|
+
--layer CPAD_SuperUnits \
|
|
76
|
+
--h3-resolution 10 \
|
|
77
|
+
--parent-resolutions "9,8,0" \
|
|
78
|
+
--hex-memory 32Gi \
|
|
79
|
+
--max-completions 200 \
|
|
80
|
+
--max-parallelism 50
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This generates YAML files for a 5-step pipeline:
|
|
84
|
+
|
|
85
|
+
1. **setup-bucket** — creates the S3 bucket with public-read policy
|
|
86
|
+
2. **convert** — reads source data, reprojects to EPSG:4326, writes GeoParquet
|
|
87
|
+
3. **pmtiles** — converts GeoParquet to PMTiles (parallel with step 4)
|
|
88
|
+
4. **hex** — computes H3 cell assignments in parallel pods
|
|
89
|
+
5. **repartition** — consolidates hex chunks into hive-partitioned layout
|
|
90
|
+
|
|
91
|
+
**Multiple sources:** Add `--source-url` multiple times to merge datasets:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cng-datasets workflow \
|
|
95
|
+
--dataset merged-regions \
|
|
96
|
+
--source-url https://example.com/region1.shp \
|
|
97
|
+
--source-url https://example.com/region2.shp \
|
|
98
|
+
--source-url https://example.com/region3.shp \
|
|
99
|
+
--bucket my-bucket
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Apply them:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
kubectl apply -f <output-dir>/workflow-rbac.yaml
|
|
106
|
+
kubectl apply -f <output-dir>/configmap.yaml
|
|
107
|
+
kubectl apply -f <output-dir>/workflow.yaml
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The workflow orchestrator runs steps sequentially, launching pmtiles and hex in parallel.
|
|
111
|
+
|
|
112
|
+
### Generate a raster processing pipeline
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cng-datasets raster-workflow \
|
|
116
|
+
--dataset wetlands-cog \
|
|
117
|
+
--source-url https://example.com/wetlands.tif \
|
|
118
|
+
--bucket public-wetlands
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Multi-layer sources
|
|
122
|
+
|
|
123
|
+
For GeoDatabase or GeoPackage files with multiple layers, run one workflow per layer. Use `--layer` to select each layer and `--dataset` with `/` for hierarchical S3 paths:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Inspect layers
|
|
127
|
+
ogrinfo /vsicurl/https://example.com/data.gdb
|
|
128
|
+
|
|
129
|
+
# Process each layer separately
|
|
130
|
+
cng-datasets workflow --dataset mydata/layer-a --layer LayerA ...
|
|
131
|
+
cng-datasets workflow --dataset mydata/layer-b --layer LayerB ...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The `/` in `--dataset` creates nested S3 paths (e.g., `mydata/layer-a.parquet`) while using hyphens for k8s resource names.
|
|
135
|
+
|
|
136
|
+
## CLI Reference
|
|
137
|
+
|
|
138
|
+
| Command | Purpose |
|
|
139
|
+
|---------|---------|
|
|
140
|
+
| `cng-datasets workflow` | Generate vector processing k8s pipeline |
|
|
141
|
+
| `cng-datasets raster-workflow` | Generate raster processing k8s pipeline |
|
|
142
|
+
| `cng-datasets storage setup-bucket` | Create and configure an S3 bucket |
|
|
143
|
+
| `cng-convert-to-parquet` | Convert vector data to GeoParquet |
|
|
144
|
+
| `cng-datasets vector` | Run H3 hex tiling (used inside k8s pods) |
|
|
145
|
+
| `cng-datasets raster` | Run raster H3 tiling (used inside k8s pods) |
|
|
146
|
+
| `cng-datasets repartition` | Consolidate hex chunks (used inside k8s pods) |
|
|
147
|
+
|
|
148
|
+
Commands marked "used inside k8s pods" are called by the generated jobs — you don't run them directly.
|
|
149
|
+
|
|
150
|
+
### `cng-datasets workflow` options
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
--dataset NAME Dataset name for S3 paths. Use / for hierarchy (e.g., "padus/fee").
|
|
154
|
+
--source-url URL Public URL to source data.
|
|
155
|
+
--bucket BUCKET Target S3 bucket name.
|
|
156
|
+
--layer LAYER Layer name for multi-layer sources (GDB, GPKG).
|
|
157
|
+
--h3-resolution N H3 resolution for hex tiling (default: 10).
|
|
158
|
+
--parent-resolutions STR Comma-separated parent resolutions (default: "9,8,0").
|
|
159
|
+
--hex-memory SIZE Memory per hex pod (default: 8Gi).
|
|
160
|
+
--max-completions N Number of parallel chunks, max 200 (default: auto).
|
|
161
|
+
--max-parallelism N Max concurrent pods (default: 50).
|
|
162
|
+
--id-column COL ID column name (auto-detected if omitted).
|
|
163
|
+
--output-dir DIR Directory for generated YAML files.
|
|
164
|
+
--intermediate-chunk-size Rows per unnest batch (decrease if OOM).
|
|
165
|
+
--row-group-size N Rows per parquet row group (default: 100000).
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## S3 Output Layout
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
bucket/
|
|
172
|
+
├── dataset.parquet # GeoParquet
|
|
173
|
+
├── dataset.pmtiles # PMTiles
|
|
174
|
+
├── dataset/
|
|
175
|
+
│ └── hex/
|
|
176
|
+
│ └── h0={cell}/data_0.parquet # H3-indexed, hive-partitioned
|
|
177
|
+
├── README.md
|
|
178
|
+
└── stac-collection.json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Docker
|
|
182
|
+
|
|
183
|
+
The CLI and all dependencies are packaged in a Docker image used by the k8s jobs:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
docker pull ghcr.io/boettiger-lab/datasets:latest
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Troubleshooting
|
|
190
|
+
|
|
191
|
+
**OOM on hex jobs:** Increase `--hex-memory` (e.g., 32Gi → 64Gi), increase `--max-completions` for smaller chunks, or decrease `--intermediate-chunk-size`.
|
|
192
|
+
|
|
193
|
+
**Convert fails on curved geometries (MULTISURFACE):** Handled automatically — the converter linearizes curved geometry types via ogr2ogr before processing.
|
|
194
|
+
|
|
195
|
+
**Monitoring:**
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
kubectl get jobs # Pipeline status
|
|
199
|
+
kubectl logs job/<name> # Job logs
|
|
200
|
+
kubectl get pods | grep OOM # Check for memory issues
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pip install -e ".[dev]"
|
|
207
|
+
pytest tests/
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
Apache 2.0
|
|
213
|
+
|
|
214
|
+
## Citation
|
|
215
|
+
|
|
216
|
+
If you use cng-datasets in your work, please cite it via its Zenodo archive.
|
|
217
|
+
The DOI badge at the top of this README resolves to the latest release; each
|
|
218
|
+
release also has its own version-specific DOI. Citation metadata (authors,
|
|
219
|
+
title, funding) lives in [`.zenodo.json`](.zenodo.json) and is minted
|
|
220
|
+
automatically by Zenodo on each GitHub release.
|
|
221
|
+
|
|
222
|
+
> Boettiger, C., & Buhler, C. K. cng-datasets: A cloud-native toolkit for
|
|
223
|
+
> processing large geospatial datasets on Kubernetes. Zenodo.
|
|
224
|
+
> https://zenodo.org/badge/latestdoi/921944685
|
|
225
|
+
|
|
226
|
+
Once the first release is archived on Zenodo, replace the redirect above with
|
|
227
|
+
the concrete versioned DOI it mints.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# cng-datasets
|
|
2
|
+
|
|
3
|
+
[](https://zenodo.org/badge/latestdoi/921944685)
|
|
4
|
+
|
|
5
|
+
A CLI toolkit for processing large geospatial datasets into cloud-native formats on Kubernetes.
|
|
6
|
+
|
|
7
|
+
**What it does:** Takes source geospatial data (Shapefiles, GeoPackages, FileGDB, GeoTIFFs) and produces:
|
|
8
|
+
|
|
9
|
+
- **GeoParquet** — columnar format for analytical queries (DuckDB, Polars)
|
|
10
|
+
- **PMTiles** — vector tiles for web map visualization
|
|
11
|
+
- **H3 Hex Parquet** — hexagonal grid indexed at configurable H3 resolution, hive-partitioned for fast spatial joins
|
|
12
|
+
- **Cloud-Optimized GeoTIFF** — for raster data, optimized for HTTP range requests
|
|
13
|
+
|
|
14
|
+
**How it works:** You run a single CLI command locally. It generates Kubernetes Job YAML files that orchestrate the entire pipeline on your cluster. You never process data on your local machine — the CLI just generates the jobs.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install cng-datasets
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or from source:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e "."
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Generate a vector processing pipeline
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cng-datasets workflow \
|
|
34
|
+
--dataset cpad-2024 \
|
|
35
|
+
--source-url https://example.com/cpad.gdb \
|
|
36
|
+
--bucket public-cpad \
|
|
37
|
+
--layer CPAD_SuperUnits \
|
|
38
|
+
--h3-resolution 10 \
|
|
39
|
+
--parent-resolutions "9,8,0" \
|
|
40
|
+
--hex-memory 32Gi \
|
|
41
|
+
--max-completions 200 \
|
|
42
|
+
--max-parallelism 50
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This generates YAML files for a 5-step pipeline:
|
|
46
|
+
|
|
47
|
+
1. **setup-bucket** — creates the S3 bucket with public-read policy
|
|
48
|
+
2. **convert** — reads source data, reprojects to EPSG:4326, writes GeoParquet
|
|
49
|
+
3. **pmtiles** — converts GeoParquet to PMTiles (parallel with step 4)
|
|
50
|
+
4. **hex** — computes H3 cell assignments in parallel pods
|
|
51
|
+
5. **repartition** — consolidates hex chunks into hive-partitioned layout
|
|
52
|
+
|
|
53
|
+
**Multiple sources:** Add `--source-url` multiple times to merge datasets:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cng-datasets workflow \
|
|
57
|
+
--dataset merged-regions \
|
|
58
|
+
--source-url https://example.com/region1.shp \
|
|
59
|
+
--source-url https://example.com/region2.shp \
|
|
60
|
+
--source-url https://example.com/region3.shp \
|
|
61
|
+
--bucket my-bucket
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Apply them:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
kubectl apply -f <output-dir>/workflow-rbac.yaml
|
|
68
|
+
kubectl apply -f <output-dir>/configmap.yaml
|
|
69
|
+
kubectl apply -f <output-dir>/workflow.yaml
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The workflow orchestrator runs steps sequentially, launching pmtiles and hex in parallel.
|
|
73
|
+
|
|
74
|
+
### Generate a raster processing pipeline
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cng-datasets raster-workflow \
|
|
78
|
+
--dataset wetlands-cog \
|
|
79
|
+
--source-url https://example.com/wetlands.tif \
|
|
80
|
+
--bucket public-wetlands
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Multi-layer sources
|
|
84
|
+
|
|
85
|
+
For GeoDatabase or GeoPackage files with multiple layers, run one workflow per layer. Use `--layer` to select each layer and `--dataset` with `/` for hierarchical S3 paths:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Inspect layers
|
|
89
|
+
ogrinfo /vsicurl/https://example.com/data.gdb
|
|
90
|
+
|
|
91
|
+
# Process each layer separately
|
|
92
|
+
cng-datasets workflow --dataset mydata/layer-a --layer LayerA ...
|
|
93
|
+
cng-datasets workflow --dataset mydata/layer-b --layer LayerB ...
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The `/` in `--dataset` creates nested S3 paths (e.g., `mydata/layer-a.parquet`) while using hyphens for k8s resource names.
|
|
97
|
+
|
|
98
|
+
## CLI Reference
|
|
99
|
+
|
|
100
|
+
| Command | Purpose |
|
|
101
|
+
|---------|---------|
|
|
102
|
+
| `cng-datasets workflow` | Generate vector processing k8s pipeline |
|
|
103
|
+
| `cng-datasets raster-workflow` | Generate raster processing k8s pipeline |
|
|
104
|
+
| `cng-datasets storage setup-bucket` | Create and configure an S3 bucket |
|
|
105
|
+
| `cng-convert-to-parquet` | Convert vector data to GeoParquet |
|
|
106
|
+
| `cng-datasets vector` | Run H3 hex tiling (used inside k8s pods) |
|
|
107
|
+
| `cng-datasets raster` | Run raster H3 tiling (used inside k8s pods) |
|
|
108
|
+
| `cng-datasets repartition` | Consolidate hex chunks (used inside k8s pods) |
|
|
109
|
+
|
|
110
|
+
Commands marked "used inside k8s pods" are called by the generated jobs — you don't run them directly.
|
|
111
|
+
|
|
112
|
+
### `cng-datasets workflow` options
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
--dataset NAME Dataset name for S3 paths. Use / for hierarchy (e.g., "padus/fee").
|
|
116
|
+
--source-url URL Public URL to source data.
|
|
117
|
+
--bucket BUCKET Target S3 bucket name.
|
|
118
|
+
--layer LAYER Layer name for multi-layer sources (GDB, GPKG).
|
|
119
|
+
--h3-resolution N H3 resolution for hex tiling (default: 10).
|
|
120
|
+
--parent-resolutions STR Comma-separated parent resolutions (default: "9,8,0").
|
|
121
|
+
--hex-memory SIZE Memory per hex pod (default: 8Gi).
|
|
122
|
+
--max-completions N Number of parallel chunks, max 200 (default: auto).
|
|
123
|
+
--max-parallelism N Max concurrent pods (default: 50).
|
|
124
|
+
--id-column COL ID column name (auto-detected if omitted).
|
|
125
|
+
--output-dir DIR Directory for generated YAML files.
|
|
126
|
+
--intermediate-chunk-size Rows per unnest batch (decrease if OOM).
|
|
127
|
+
--row-group-size N Rows per parquet row group (default: 100000).
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## S3 Output Layout
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
bucket/
|
|
134
|
+
├── dataset.parquet # GeoParquet
|
|
135
|
+
├── dataset.pmtiles # PMTiles
|
|
136
|
+
├── dataset/
|
|
137
|
+
│ └── hex/
|
|
138
|
+
│ └── h0={cell}/data_0.parquet # H3-indexed, hive-partitioned
|
|
139
|
+
├── README.md
|
|
140
|
+
└── stac-collection.json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Docker
|
|
144
|
+
|
|
145
|
+
The CLI and all dependencies are packaged in a Docker image used by the k8s jobs:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
docker pull ghcr.io/boettiger-lab/datasets:latest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Troubleshooting
|
|
152
|
+
|
|
153
|
+
**OOM on hex jobs:** Increase `--hex-memory` (e.g., 32Gi → 64Gi), increase `--max-completions` for smaller chunks, or decrease `--intermediate-chunk-size`.
|
|
154
|
+
|
|
155
|
+
**Convert fails on curved geometries (MULTISURFACE):** Handled automatically — the converter linearizes curved geometry types via ogr2ogr before processing.
|
|
156
|
+
|
|
157
|
+
**Monitoring:**
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
kubectl get jobs # Pipeline status
|
|
161
|
+
kubectl logs job/<name> # Job logs
|
|
162
|
+
kubectl get pods | grep OOM # Check for memory issues
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pip install -e ".[dev]"
|
|
169
|
+
pytest tests/
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
Apache 2.0
|
|
175
|
+
|
|
176
|
+
## Citation
|
|
177
|
+
|
|
178
|
+
If you use cng-datasets in your work, please cite it via its Zenodo archive.
|
|
179
|
+
The DOI badge at the top of this README resolves to the latest release; each
|
|
180
|
+
release also has its own version-specific DOI. Citation metadata (authors,
|
|
181
|
+
title, funding) lives in [`.zenodo.json`](.zenodo.json) and is minted
|
|
182
|
+
automatically by Zenodo on each GitHub release.
|
|
183
|
+
|
|
184
|
+
> Boettiger, C., & Buhler, C. K. cng-datasets: A cloud-native toolkit for
|
|
185
|
+
> processing large geospatial datasets on Kubernetes. Zenodo.
|
|
186
|
+
> https://zenodo.org/badge/latestdoi/921944685
|
|
187
|
+
|
|
188
|
+
Once the first release is archived on Zenodo, replace the redirect above with
|
|
189
|
+
the concrete versioned DOI it mints.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cloud-Native Geospatial Datasets Processing Toolkit
|
|
3
|
+
|
|
4
|
+
A toolkit for processing large geospatial datasets into cloud-native formats
|
|
5
|
+
(COG, GeoParquet, PMTiles) with H3 hexagonal indexing.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.3.0"
|
|
9
|
+
|
|
10
|
+
# Lazy imports can be handled by users as needed,
|
|
11
|
+
# or we can keep these commented out to allow core usage without all dependencies.
|
|
12
|
+
# from . import vector, raster, k8s, storage
|
|
13
|
+
# __all__ = ["vector", "raster", "k8s", "storage", "__version__"]
|