Skip to content

fix: Retain tiled structure of original AEF embedding & resize to 16x16 - #79

Merged
weiji14 merged 3 commits into
mainfrom
aef-tiled-zstd
Oct 12, 2026
Merged

weiji14 merged 3 commits into
mainfrom
aef-tiled-zstd

Conversation

@weiji14

@weiji14 weiji14 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

The sample 10x10 clipped AEF embedding TIFF did not maintain the original tiled structure, nor the ZSTD compression. Need to modify the gdal raster clip command's output options to ensure these aspects from the original AEF embedding TIFF are preserved in the sample file.

For ref, the original AEF TIFF is at https://source.coop/tge-labs/aef/v1/annual/2024/13N/xjejfvrbm1fbu1ecw-0000000000-0000008192.tiff. Output from AWS_NO_SIGN_REQUEST=YES gdal info /vsis3/us-west-2.opendata.source.coop/tge-labs/aef/v1/annual/2024/13N/xjejfvrbm gives (truncated):

Driver: GTiff/GeoTIFF
Files: /vsis3/us-west-2.opendata.source.coop/tge-labs/aef/v1/annual/2024/13N/xjejfvrbm1fbu1ecw-0000000000-0000008192.tiff
Size is 8192, 8192
Coordinate System is:
PROJCRS["WGS 84 / UTM zone 13N",
    ...
    ID["EPSG",32613]]
Data axis to CRS axis mapping: 1,2
Origin = (418080.000000000000000,4423680.000000000000000)
Pixel Size = (10.000000000000000,10.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  LAYOUT=COG
  COMPRESSION=ZSTD
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  418080.000, 4423680.000) (105d57'32.85"W, 39d57'33.47"N)
Lower Left  (  418080.000, 4505600.000) (105d58'10.67"W, 40d41'50.04"N)
Upper Right (  500000.000, 4423680.000) (105d 0' 0.00"W, 39d57'47.75"N)
Lower Right (  500000.000, 4505600.000) (105d 0' 0.00"W, 40d42' 4.70"N)
Center      (  459040.000, 4464640.000) (105d28'55.88"W, 40d19'52.65"N)
Band 1 Block=1024x1024 Type=Int8, ColorInterp=Gray
  Description = A00
  NoData Value=-128
  Overviews: 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4, 2x2, 1x1
Band 2 Block=1024x1024 Type=Int8, ColorInterp=Undefined
  Description = A01
  NoData Value=-128
  Overviews: 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4, 2x2, 1x1
Band 3 Block=1024x1024 Type=Int8, ColorInterp=Undefined
  Description = A02
  NoData Value=-128
  Overviews: 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4, 2x2, 1x1
...
Band 60 Block=1024x1024 Type=Int8, ColorInterp=Undefined
  Description = A59
  NoData Value=-128

Technically the AEF embedding TIFF is a COG, but COGs created by GDAL have a minimum blocksize of 128 apparently. So we'll just go with a regular TILED GeoTIFF with blocksize 16 to keep the file small.

Discovered the mistake while working on developmentseed/async-tiff#251, patches #34

The 10x10 clipped image did not maintain the original COG's tiled structure, nor the ZSTD compression and overviews. Modified the `gdal raster clip` command's output options to ensure these features from the original AEF embedding TIFF are preserved.
@weiji14 weiji14 added the bug Something isn't working label Oct 12, 2026
--window 0,0,10,10 \
--output-format COG \
--creation-option COMPRESS=ZSTD \
--creation-option INTERLEAVE=BAND \

@weiji14 weiji14 Oct 12, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to explicitly set INTERLEAVE=BAND otherwise GDAL defaults to INTERLEAVE=PIXEL apparently (see https://gdal.org/en/stable/drivers/raster/cog.html#general-creation-options).

@weiji14
weiji14 marked this pull request as draft October 12, 2026 02:49
COGs created by GDAL have a minimum BlockSize of 128, so just go with a regular TILED GeoTIFF, that has a minimum BlockSize of 16. No more overview levels.
@weiji14 weiji14 changed the title fix: Keep sample AEF embedding tiff's original tiled COG structure fix: Keep sample AEF embedding tiff's original tiled structure Oct 12, 2026
IFD
Id Size BlockSize Decimation
0 10x10 10x10 0
0 10x10 16x16 0

@weiji14 weiji14 Oct 12, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change the crop window from 10x10 to 16x16 to follow the minimum blocksize? This will increase the filesize from 12.3kB to 17.3kB.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's fine

To match blocksize of 16x16. Note that it says Tiled=False, but technically it is tiled...
@weiji14 weiji14 changed the title fix: Keep sample AEF embedding tiff's original tiled structure fix: Retain sample AEF embedding tiff's original tiled structure Oct 12, 2026
@weiji14
weiji14 marked this pull request as ready for review October 12, 2026 21:00
@weiji14 weiji14 changed the title fix: Retain sample AEF embedding tiff's original tiled structure fix: Retain tiled structure of original AEF embedding & resize to 16x16 Oct 12, 2026
Width: 16
Height: 16
Bands: 64
Tiled: False

@weiji14 weiji14 Oct 12, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why cogeo info says this is not tiled when the width/height (16x16) matches the blocksize (16x16). Maybe because for a TIFF with a single tile, there is no difference between a tiled vs a striped TIFF?

At least async-tiff won't error with Not a tiled tiff anymore 🙂

@weiji14
weiji14 merged commit 0b1055b into main Oct 12, 2026
1 check passed
@weiji14
weiji14 deleted the aef-tiled-zstd branch October 12, 2026 21:04
weiji14 added a commit to developmentseed/async-tiff that referenced this pull request Oct 12, 2026
Try pulling 3 bands out of 64 from the sample AlphaEarth Foundations embedding TIFF dataset. Updated geotiff-test-data from b7158c4 to 0b1055b which includes the tiled sample AEF embedding TIFF from developmentseed/geotiff-test-data#79
weiji14 added a commit to developmentseed/async-tiff that referenced this pull request Oct 22, 2026
…IFF (#251)

* Add band-interleaved multi-band sample TIFF
* Fetch range of bands for a tile instead of all bands
* Add specific test pulling specific band ranges from a TIFF

* Enable fetching disjoint bands from a TIFF

Change from passing in a Range<usize> to a Vec<usize> so specific bands can be indexed.

* Change parameters from just bands to more extensible fetch_options

Create a FetchOptions struct that allows passing specific parameters (currently only `bands`) when doing a fetch_tile operation. Keep the existing option of passing only None to do the default action of fetching of all bands.

* Check that we are not fetching bands outside the max band count

With some special handling to handle 0-based indexing.

* Support fetching specific bands with `fetch_tiles`

Use the same FetchOptions struct, included another unit test using the eox_cloudless.tif data as test case.

* Rename to ReadOptions

* Enable fetching specific bands via TIFF.fetch_tile and .fetch_tiles

Add `bands` kwarg to TIFF.fetch_tile and TIFF.fetch_tiles to allow fetching only specific bands (or by default, all bands when `None` is given). Included a unit test to ensure it is possible to fetch only 2 bands from an RGB TIFF.

* Update geotiff-test-data from efc3ee1 to b7158c4

Include updated uint8_1band_deflate_block128_unaligned_predictor2.tif file from developmentseed/geotiff-test-data#74

* Change unit test to check against AEF embedding dataset with 64 bands

Try pulling 3 bands out of 64 from the sample AlphaEarth Foundations embedding TIFF dataset. Updated geotiff-test-data from b7158c4 to 0b1055b which includes the tiled sample AEF embedding TIFF from developmentseed/geotiff-test-data#79

* Rename fetch_options parameter to read_options

Following the ReadOptions struct name used in 72e1071

* Change bands/planes to be kwarg only

* Rename bands -> planes

Xref #360

* Clarify that planes arguments should be using 0-based indexing

E.g. [0, 1, 2] for the first three planes/bands.

---------

Co-authored-by: Kyle Barron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants