opendatacube / odc-geo

GeoBox and geometry utilities extracted from datacube-core
https://odc-geo.readthedocs.io/en/latest/
Apache License 2.0
80 stars 12 forks source link

Add tag writing support including scale, offset and units special cases #146

Closed alexgleith closed 5 months ago

alexgleith commented 5 months ago

Added a simple test.

Open to feedback on a better method, but I think this works ok and hopefully handles all cases!

github-actions[bot] commented 5 months ago

🚀 Deployed on https://66330e492587185dac79173b--odc-geo-docs.netlify.app

alexgleith commented 5 months ago

So, I checked, and all these tags and special metadata items are written to the GDAL section in the tif metadata:

  GDAL Metadata: <GDALMetadata>
  <Item name="random_tag">random_value</Item>
  <Item name="OFFSET" sample="0" role="offset">0.989999999999999991</Item>
  <Item name="SCALE" sample="0" role="scale">100</Item>
  <Item name="UNITTYPE" sample="0" role="unittype">microwaves</Item>
</GDALMetadata>
Kirill888 commented 5 months ago

This is all fine, I do have issue with the name tags: since this is TIFF making function, my first assumption is that tags refers to TIFF tags and not to "GDAL" tags, aka gdal metadata items, or general "annotation" of some sort. On the other hand that's the nomenclature used by rioxarray also, so...

Kirill888 commented 5 months ago

@alexgleith do you want to rebase this into one clean commit and maybe add a note to docs clarifying that tags refer to "GDAL tags/metadata". As a person who actually read TIFF spec I'm probably biased in my interpretation of tags, but it won't hurt being more precise about it.

alexgleith commented 5 months ago

Thanks, @Kirill888. I've refactored to simplify the multi-band case a bit.

Can you please check my logic looks like it'll work? I think it's ok...