Skip to content

Commit 43ea500

Browse files
authored
Merge pull request #886 from Open-EO/883-predefined-tilegrid-splitter
add support for predefinedtilegrid in split_area #883
2 parents 7ef21c6 + b283567 commit 43ea500

8 files changed

Lines changed: 823 additions & 239 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Add public `split_area` function for tile-grid based job splitting
13+
1214
### Changed
1315

1416
### Removed

docs/cookbook/job_manager.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,44 @@ You can implement your own storage backend by subclassing
227227
:py:class:`~openeo.extra.job_management.JobDatabaseInterface`.
228228
See the :ref:`API reference below <job-manager-api-reference>` for the full interface.
229229

230+
Job Splitting
231+
============
232+
233+
The :py:func:`~openeo.extra.job_management._job_splitting.split_area` helper function allows you to split a large area of interest into smaller areas, which can then be processed as separate jobs.
234+
A user may have a large spatial extent, in the form of a bounding box or polygon, that exceeds the processing limits of a single job on the backend.
235+
The results are returned as a :py:class:`geopandas.GeoDataFrame` with one row per tile, which can be used as the starting point for a job database where each row corresponds to a manageable job.
236+
237+
The spatial extent can either be split into a regular grid of square tiles, with fixed size and projection, or into a custom grid of variable tiles provided by the user.
238+
239+
Example: splitting a bounding box into 10x10 km tiles in EPSG:3857:
240+
241+
.. code-block:: python
242+
243+
from openeo.extra.job_management import split_area
244+
245+
# Define the bounding box to split
246+
bbox = {"west": 5.0, "south": 51.0, "east": 5.2, "north": 51.2, "crs": "EPSG:4326"}
247+
248+
# Split into 10x10 km tiles in EPSG:3857
249+
gdf = split_area(
250+
aoi=bbox,
251+
tile_size=10_000, # tile size in meters (units of the projection)
252+
projection="EPSG:3857", # projection for tiling
253+
)
254+
255+
This will create a GeoDataFrame with one row per tile, and a geometry column containing the tile polygons.
256+
257+
.. code-block:: pycon
258+
259+
>>> gdf.head()
260+
geometry
261+
0 POLYGON ((566597.454 6621293.723, 566597.454 6...
262+
1 POLYGON ((566597.454 6631293.723, 566597.454 6...
263+
2 POLYGON ((566597.454 6641293.723, 566597.454 6...
264+
3 POLYGON ((566597.454 6651293.723, 566597.454 6...
265+
4 POLYGON ((576597.454 6621293.723, 576597.454 6...
266+
267+
Note that while the original bounding box was in EPSG:4326, the resulting GeoDataFrame is in the tiling projection (EPSG:3857 in this case).
230268

231269
Customizing Job Handling
232270
========================

openeo/extra/job_management/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
create_job_db,
77
get_job_db,
88
)
9+
from openeo.extra.job_management._job_splitting import split_area
910
from openeo.extra.job_management._manager import MultiBackendJobManager
1011
from openeo.extra.job_management.process_based import ProcessBasedJobCreator
1112

@@ -17,5 +18,6 @@
1718
"ProcessBasedJobCreator",
1819
"create_job_db",
1920
"get_job_db",
21+
"split_area",
2022
"MultiBackendJobManager",
2123
]

0 commit comments

Comments
 (0)