Repository navigation
MODIS: restore projection extension on new items - #387
Merged
Merged
Conversation
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
Gustavo Hidalgo (ghidalgo3)
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MODIS items created since #351 have no projection extension: no
proj:wkt2,proj:transform,proj:shapeorproj:geometry. #351 moved to stactools-modis8854ceb, whose builder only reads projection from COGs passed to it. This collection attaches COGs afterwards with the deprecatedadd_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 haveproj:geometryon only some rows, which stac-geoparquet cannot read.This adds
add_projection(), called right aftercreate_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 requestsWktVersion.WKT2_2019explicitly: the oldcrs.to_wkt("WKT2")passed the string asmorph_to_esri_dialect, so older items stored ESRI WKT1 inproj:wkt2.Items already created without projection need reprocessing to pick this up.
Type of change
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 fromdatasets/modiswithpython -m pytest --noconftest tests/test_projection.py.add_projectionto the liveMOD10A1.A2000057.h23v07.061.2020037182526item, using its COG in place of the HDF (local GDAL lacks HDF4).proj:transform,proj:shapeandproj:geometryequal 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.Note:
datasets/modis/tests/test_platform_field.pyimportsdatasets.modis.misc, which #351 deleted; it is left unchanged.Checklist: