Commit 03d7380
authored
* Inherit georef from level-0 IFD when reading overview IFDs (#1640)
GDAL-style COG writers, including this package's own to_geotiff, put
the GeoKeyDirectory, ModelPixelScale, and ModelTiepoint only on the
level-0 IFD. Before this fix, open_geotiff(path, overview_level=N)
with N >= 1 returned a DataArray whose CRS, transform attr, and y/x
coords were silently replaced with defaults (unit transform, integer
pixel indices, no crs). Downstream spatial ops then computed pixel
sizes from the wrong coords and produced silently-wrong answers.
Add extract_geo_info_with_overview_inheritance in _geotags.py. When
the selected IFD is a reduced-resolution overview (NewSubfileType bit
0) and its own extract_geo_info reports has_georef=False, the helper
re-runs extract_geo_info on the first full-resolution IFD and rescales
the pixel size by width_full / width_overview (and the same for
height) before copying CRS-side metadata across. Overviews that
already carry their own valid georef (some writers replicate it) are
left untouched.
Wire the helper into every read entry point:
- read_to_array (eager numpy and dask chunk workers)
- _read_cog_http (HTTP COGs)
- _read_geo_info (dask metadata probe)
- read_geotiff_gpu (cupy and dask+cupy paths)
Add xrspatial/geotiff/tests/test_overview_geo_inheritance_1640.py
covering all four backends (numpy, dask+numpy, cupy, dask+cupy) plus
two edge cases: an overview that carries its own geokeys keeps them,
and a file with no full-res sibling falls back without raising.
* Update sweep-metadata state for geotiff (#1640)
1 parent 977968f commit 03d7380
5 files changed
Lines changed: 449 additions & 7 deletions
File tree
- .claude
- xrspatial/geotiff
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
| |||
2264 | 2267 | | |
2265 | 2268 | | |
2266 | 2269 | | |
2267 | | - | |
| 2270 | + | |
2268 | 2271 | | |
2269 | 2272 | | |
2270 | 2273 | | |
| |||
2301 | 2304 | | |
2302 | 2305 | | |
2303 | 2306 | | |
2304 | | - | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
2305 | 2311 | | |
2306 | 2312 | | |
2307 | 2313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
675 | 799 | | |
676 | 800 | | |
677 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
1236 | 1237 | | |
1237 | 1238 | | |
1238 | 1239 | | |
1239 | | - | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1240 | 1247 | | |
1241 | 1248 | | |
1242 | 1249 | | |
| |||
1586 | 1593 | | |
1587 | 1594 | | |
1588 | 1595 | | |
1589 | | - | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
1590 | 1602 | | |
1591 | 1603 | | |
1592 | 1604 | | |
| |||
0 commit comments