Skip to content

MODIS: restore projection extension on new items - #387

Merged
DerekTan1 merged 1 commit into
mainfrom
tanderek/modis-restore-projection
Oct 15, 2026
Merged

DerekTan1 merged 1 commit into
mainfrom
tanderek/modis-restore-projection

Conversation

@DerekTan1

Copy link
Copy Markdown
Contributor

Description

MODIS items created since #351 have no projection extension: no proj:wkt2, proj:transform, proj:shape or proj:geometry. #351 moved to stactools-modis 8854ceb, whose builder only reads projection from COGs passed to it. This collection attaches COGs afterwards with the deprecated add_cogs / add_cog_assets, which never set projection.

In OpenPC, every MODIS item dated mid-June 2025 onward lacks projection, as does all of modis-10A1-061, while older items still carry it. Partitions mixing the two have proj:geometry on only some rows, which stac-geoparquet cannot read.

This adds add_projection(), called right after create_item. It opens the local HDF's first subdataset once per item, as stactools-modis did before #351. Every MODIS asset shares one sinusoidal tile grid, so one read covers the item; no SAS or extra download is needed. It requests WktVersion.WKT2_2019 explicitly: the old crs.to_wkt("WKT2") passed the string as morph_to_esri_dialect, so older items stored ESRI WKT1 in proj:wkt2.

Items already created without projection need reprocessing to pick this up.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • datasets/modis/tests/test_projection.py: 2 new tests (projection fields from a GeoTIFF on the MODIS grid standing in for the HDF subdataset; error when the HDF has no subdatasets). Run from datasets/modis with python -m pytest --noconftest tests/test_projection.py.
  • Applied add_projection to the live MOD10A1.A2000057.h23v07.061.2020037182526 item, using its COG in place of the HDF (local GDAL lacks HDF4). proj:transform, proj:shape and proj:geometry equal the values the item had before it was re-created, with the same CRS as real WKT2 (projection v2.0.0, proj:code: null). The item passes GeoCatalog's STAC validator.
  • Every MODIS COG header (19 collections) shares one projection per item, so a single read per item is sufficient.

Note: datasets/modis/tests/test_platform_field.py imports datasets.modis.misc, which #351 deleted; it is left unchanged.

Checklist:

  • I have performed a self-review
  • Unit tests pass locally for the new MODIS projection tests
  • Code is linted (flake8 rules, max line length 120)

Since #351 moved to stactools-modis 8854ceb, items carry no projection:
the new stactools builder only reads projection from COGs passed to it,
and this collection attaches COGs afterwards with add_cogs/add_cog_assets.

Read the projection once per item from the local HDF's first subdataset
(every MODIS asset shares one sinusoidal tile grid), as stactools-modis did
before. Use WktVersion.WKT2_2019 explicitly: to_wkt("WKT2") passed the
string as morph_to_esri_dialect, so older items stored ESRI WKT1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ccc413ed-d53b-400b-8314-a0aa9a9f48f4
@DerekTan1
DerekTan1 merged commit 4c11f68 into main Oct 15, 2026
5 of 6 checks passed
@DerekTan1
DerekTan1 deleted the tanderek/modis-restore-projection branch October 15, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants