Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add support for merging tiffs with different CRS #2697

Closed
wants to merge 1 commit into from

Conversation

VehpuS
Copy link

@VehpuS VehpuS commented Dec 30, 2022

(Following #2696)

I have been looking into the implementation of rasterio.merge.merge to "prefetch" common bounds from a group of rasters. Once working on my implementation (since the function isn't currently too modular) I realized that I was getting errors when calculating common bounds of tiffs.

After some investigation, it turns out this was because the CRS of each tif was different, resulting in bounds given in different units. Before implementing my own solution, I looked at the merge implementation again but found no consideration for this. In the end, I implemented a solution based on rasterio.warp.transform_bounds.

I currently implemented this solution with a separate function since it may be a backward breaking change and I'm not sure whether that is something that would be appreciated. I replicated all existing tests for the new merge function (with support for multiple CRSs) but still need to add tests to check the feature specifically (i.e. actively try to merge tiffs with different CRSs).

out_profile["nodata"] = nodata

# create destination array
dest = np.zeros((output_count, output_height, output_width), dtype=dt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an important implementation detail: the merge cannot deal with arbitrarily large datasets that wouldn't fit in RAM. Using GDALWarp() would avoid that limitation

@sgillies
Copy link
Member

@VehpuS Thanks for the suggestion. Merging TIFFs with different CRS is by nature a reprojection/warping problem. Rasterio's merge is about combining data that is already aligned. Tiles, and that kind of thing. I don't want to blur the distinction. I agree that a tool to merge heterogenous collections of data would be useful, but I'm not eager to add this to Rasterio. Rasterio needs to focus on making low level raster data access better.

@sgillies sgillies closed this Dec 19, 2023
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.

None yet

4 participants