zarr-developers / geozarr-spec

This document aims to provides a geospatial extension to the Zarr specification. Zarr specifies a protocol and format used for storing Zarr arrays, while the present extension defines conventions and recommendations for storing multidimensional georeferenced grid of geospatial observations (including rasters).
106 stars 10 forks source link

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

Closed wietzesuijker closed 4 months ago

wietzesuijker commented 4 months ago

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:

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 commented 4 months ago

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

wietzesuijker commented 4 months ago

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

thomas-maschler commented 4 months ago

@wietzesuijker this looks very straightforward. Have you seen the discussion at https://github.com/zarr-developers/geozarr-spec/issues/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 https://github.com/zarr-developers/geozarr-spec/pull/44. I'd love to hear your thoughts on this.

wietzesuijker commented 4 months ago

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

felixcremer commented 1 month ago

@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 commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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?