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

Example: Converting GeoTIFF to GeoZarr with Overviews and Metadata #42

Closed

Conversation

wietzesuijker
Copy link

@wietzesuijker wietzesuijker commented Feb 7, 2024

Added a script that demonstrates converting a GeoTIFF file to "GeoZarr" format, incorporating pyramid overviews and relevant metadata to align with the GeoZarr specification. The script includes:

  • Generating synthetic geospatial data using numpy, xarray, rioxarray, and rasterio.
  • Saving this data as a GeoTIFF, including pyramid overviews for different resolutions.
  • Converting the GeoTIFF into a "GeoZarr" dataset, ensuring it contains necessary metadata.

Purpose: Get a mutual understanding on the format of GeoZarr for geospatial datasets.

Feedback Welcome: Suggestions for improvements or any corrections are appreciated to ensure this example is helpful and accurate.

Not necessarily proposing we add this to the spec repo, just a way to share this for PR reviews.

@wietzesuijker
Copy link
Author

Just came across earlier related work in this space zarr-developers/zarr-specs#125 and e.g. dynamic chunking at different scales.

@wietzesuijker wietzesuijker marked this pull request as draft February 8, 2024 19:06
@wietzesuijker
Copy link
Author

added another example to enable _CRS detection in QGIS, following gdal srs-encoding. This can be drag and dropped in qgis (with gdal 3.8+, which can be installed which conda install qgis).

crs_enabled_zarr_and_tif.zip

Code to reproduce

@wietzesuijker wietzesuijker marked this pull request as ready for review February 10, 2024 11:56
@thomas-maschler
Copy link

@wietzesuijker this looks very straightforward. Have you seen the discussion at #30? The question here is how you could represent the overview using both regular decimation and zoom-level style tiling. We came up with this PR as a proposal #44. I'd love to hear your thoughts on this.

@wietzesuijker
Copy link
Author

Thanks, I just approved your PR and added some feedback. Closing this PR as it has served its purpose.

@felixcremer
Copy link

@wietzesuijker I am using the example file you provided here as a test case for #46 and I saw, that the X and Y dimensions in the zarr file is shifted by 5. In the Geotiff the X dims goes from 400000 to 481910 and the Geozarr X dimension goes from 40005 to 481915.
I double checked and the values seem to be written like that in the Zarr file.
I am not sure where this shift comes from.

@wietzesuijker
Copy link
Author

@felixcremer cool, glad to see it's of some use! The "shift" is because rioxarray uses pixel centroids for the xarray grid, which I expect / find desirable.

@felixcremer
Copy link

Is this shift in the meaning of the dimension noted somewhere in the metadata of the zarr file?
Or do we implicitly assume that the coordinates are always centers of the coordinate cell?

@wietzesuijker
Copy link
Author

You could make a case to make this more explicit, but imo it's just a feature of how xarray interprets georeferenced arrays. Some further details here.

@felixcremer
Copy link

I still have some questions while working through this:
What is the purpose of the "grid_mapping": "spatial_ref" entry in the attributes?
What is the spatial_ref that is pointed to?

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.

3 participants