|
14 | 14 | entries. |
15 | 15 |
|
16 | 16 | Extracted in step 5 of issue #1813. |
| 17 | +
|
| 18 | +Attrs contract (issue #1984) |
| 19 | +---------------------------- |
| 20 | +
|
| 21 | +The keys written into ``DataArray.attrs`` by the read paths fall into |
| 22 | +three tiers. Writers honour the same split: canonical keys are emitted, |
| 23 | +compatibility aliases are read but never written when the canonical key |
| 24 | +is present, and pass-through keys are kept when the writer can |
| 25 | +reconstruct them from canonical state. |
| 26 | +
|
| 27 | +The contract version is recorded in ``attrs['_xrspatial_geotiff_contract']`` |
| 28 | +(currently ``1``). Consumers can branch on this integer if the tier |
| 29 | +split changes in a future release. |
| 30 | +
|
| 31 | +Canonical (xrspatial owns these; round-trip stable): |
| 32 | +
|
| 33 | +- ``crs``: EPSG integer code for the horizontal CRS. |
| 34 | +- ``crs_wkt``: PROJ WKT string for the horizontal CRS. Always emitted. |
| 35 | +- ``transform``: tuple of ``(origin_x, origin_y, pixel_width, pixel_height)``. |
| 36 | +- ``nodata``: declared file sentinel as stored in the GDAL_NODATA tag. The |
| 37 | + declared-vs-masked split is tracked in issue #1988; the canonical |
| 38 | + semantics here describe the intended behaviour once #1988 lands. |
| 39 | +- ``raster_type``: ``'area'`` (implicit / RasterPixelIsArea) or ``'point'`` |
| 40 | + (explicit / RasterPixelIsPoint). |
| 41 | +- ``extra_tags``: list of ``(tag_id, type_id, count, value)`` tuples for |
| 42 | + TIFF tags outside the structured set. |
| 43 | +- ``gdal_metadata``: dict parsed from the GDAL_METADATA XML tag. |
| 44 | +- ``gdal_metadata_xml``: raw GDAL_METADATA XML string. |
| 45 | +- ``x_resolution``, ``y_resolution``, ``resolution_unit``: TIFF |
| 46 | + XResolution / YResolution / ResolutionUnit values. |
| 47 | +- ``_xrspatial_geotiff_contract``: integer version of this contract. |
| 48 | +
|
| 49 | +Compatibility alias (read for ecosystem interop; writers must not emit |
| 50 | +when the canonical key is present): |
| 51 | +
|
| 52 | +- ``nodatavals``: rioxarray per-band tuple form of ``nodata``. |
| 53 | +- ``_FillValue``: CF-convention name for ``nodata``. |
| 54 | +
|
| 55 | +Best-effort pass-through (preserved when the writer can reconstruct |
| 56 | +from canonical state, otherwise dropped on round-trip): |
| 57 | +
|
| 58 | +- ``crs_name``: human-readable CRS name from the GeoKey directory. |
| 59 | +- ``geog_citation``: GeographicTypeGeoKey citation string. |
| 60 | +- ``datum_code``: GeogGeodeticDatumGeoKey value. |
| 61 | +- ``angular_units``: GeogAngularUnitsGeoKey value. |
| 62 | +- ``linear_units``: ProjLinearUnitsGeoKey value. |
| 63 | +- ``semi_major_axis``: GeogSemiMajorAxisGeoKey value. |
| 64 | +- ``inv_flattening``: GeogInvFlatteningGeoKey value. |
| 65 | +- ``projection_code``: ProjectedCSTypeGeoKey value. |
| 66 | +- ``vertical_crs``: VerticalCSTypeGeoKey value. |
| 67 | +- ``vertical_citation``: VerticalCitationGeoKey value. |
| 68 | +- ``vertical_units``: VerticalUnitsGeoKey value. |
| 69 | +- ``image_description``: TIFF ImageDescription tag. |
| 70 | +- ``extra_samples``: TIFF ExtraSamples tag. |
| 71 | +- ``colormap``, ``colormap_rgba``, ``cmap``: palette data attached to |
| 72 | + single-band paletted images. |
17 | 73 | """ |
18 | 74 | from __future__ import annotations |
19 | 75 |
|
|
0 commit comments