Skip to content

Speed up merge_tile_datasets_within_extent#148

Open
mikegraham wants to merge 2 commits intoACCESS-Cloud-Based-InSAR:devfrom
mikegraham:direct-merge
Open

Speed up merge_tile_datasets_within_extent#148
mikegraham wants to merge 2 commits intoACCESS-Cloud-Based-InSAR:devfrom
mikegraham:direct-merge

Conversation

@mikegraham
Copy link
Copy Markdown

Closes #147

Update merge_tile_datasets_within_extent to do the windowing at the rasterio level

@mikegraham mikegraham force-pushed the direct-merge branch 2 times, most recently from 2dfdf3a to 01b48a8 Compare March 9, 2026 01:56
@cmarshak
Copy link
Copy Markdown
Collaborator

Hey @mikegraham - sorry it's getting delayed. I am not going to be able to review this for a little bit (likely a couple weeks).

Hope you can use your forked version.

Also, make sure (generally) there are no breaking changes since this library is used by a few different operational libraries that rely on consistent APIs including DockerizedTopsApp with generate S1 GUNWs.

I really hate this pattern that I have from reproject_to_arr_to_match_profile:

https://github.com/ACCESS-Cloud-Based-InSAR/DockerizedTopsApp/blob/888634d7fa627fcef41f42fce5155e8ad973e94e/isce2_topsapp/localize_dem.py#L118C1-L125C50

I wish I could remove the second line e.g. if an array is passed that has shape length 2, it returns an array of similar shape, but a lot of different downstream libraries already account for this annoyance.

Anyways, thanks!

@mikegraham mikegraham force-pushed the direct-merge branch 2 times, most recently from b7b363b to f091e4a Compare March 14, 2026 18:17
rasterio.merge.merge() accepts open DatasetReader objects with a
bounds parameter. The old code manually read each tile into windowed
arrays, wrapped them in MemoryFiles, then passed those to merge(),
which reads from datasets internally anyway.

The merge bounds are computed from the union of per-tile windows
(via get_window_from_extent) to preserve identical output dimensions.
n_threads is passed through as GDAL_NUM_THREADS for decompression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve merge_tile_datasets_within_extent performance

2 participants