Skip to content

Commit

Permalink
Merge pull request #11369 from rouault/backport-11319-to-release/3.10
Browse files Browse the repository at this point in the history
[Backport 3.10] GTI: make the driver work with STAC GeoParquet files that don't have a assets.image.href field
  • Loading branch information
rouault authored Nov 27, 2024
2 parents e528abb + 1ecb3f1 commit c0194a1
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 38 deletions.
7 changes: 7 additions & 0 deletions autotest/gdrivers/data/gti/sentinel2_stac_geoparquet.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "FeatureCollection",
"name": "sentinel2_stac_geoparquet",
"features": [
{ "type": "Feature", "properties": { "type": "Feature", "stac_version": "1.1.0", "assets.rededge3.href": "https://e84-earth-search-sentinel-data.s3.us-west-2.amazonaws.com/sentinel-2-c1-l2a/12/S/VD/2023/12/S2A_T12SVD_20231213T181818_L2A/B07.tif", "assets.rededge3.title": "Red Edge 3 - 20m", "assets.rededge3.type": "image/tiff; application=geotiff; profile=cloud-optimized", "assets.rededge3.roles": [ "data", "reflectance" ], "assets.rededge3.eo:bands": [ { "name": "B07", "common_name": "rededge", "center_wavelength": 0.783, "full_width_half_max": 0.028 } ], "assets.rededge3.gsd": 20.0, "assets.rededge3.proj:shape": [ 5490, 5490 ], "assets.rededge3.proj:transform": [ 20, 0, 399960, 0, -20, 3900000 ], "assets.rededge3.raster:bands": [ { "nodata": 0, "data_type": "uint16", "spatial_resolution": 20, "scale": 0.0001, "offset": -0.1 } ], "assets.rededge3.file:checksum": "1220f2623a57da9b09fe8253c2dc9a6377227041e86d192715c6d753638cb0977d99", "assets.rededge3.file:size": 53583888, "proj:epsg": 32612, }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -112.099469246340007, 35.238074627405702 ], [ -112.086441301193005, 34.249018117524301 ], [ -111.171637815685003, 34.254252630787903 ], [ -110.892875963752005, 35.136386493702297 ], [ -110.892735914686995, 35.243021163215097 ], [ -112.099469246340007, 35.238074627405702 ] ] ] } }
]
}
34 changes: 34 additions & 0 deletions autotest/gdrivers/gti.py
Original file line number Diff line number Diff line change
Expand Up @@ -2985,3 +2985,37 @@ def test_gti_stac_geoparquet():
"Blue",
"NIR (near-infrared)",
]


###############################################################################


@pytest.mark.require_curl()
@pytest.mark.require_driver("GeoJSON")
def test_gti_stac_geoparquet_sentinel2():

url = "https://e84-earth-search-sentinel-data.s3.us-west-2.amazonaws.com/sentinel-2-c1-l2a/12/S/VD/2023/12/S2A_T12SVD_20231213T181818_L2A/B07.tif"

conn = gdaltest.gdalurlopen(url, timeout=4)
if conn is None:
pytest.skip("cannot open URL")

ds = gdal.Open("GTI:data/gti/sentinel2_stac_geoparquet.geojson")
assert ds.RasterXSize == 5556
assert ds.RasterYSize == 5540
assert ds.GetSpatialRef().GetAuthorityCode(None) == "32612"
assert ds.GetGeoTransform() == pytest.approx(
(398760.0, 20.0, 0.0, 3900560.0, 0.0, -20.0), rel=1e-5
)
assert ds.RasterCount == 1
band = ds.GetRasterBand(1)
assert band.DataType == gdal.GDT_UInt16
assert band.GetNoDataValue() == 0
assert band.GetColorInterpretation() == gdal.GCI_RedEdgeBand
assert band.GetDescription() == "B07"
assert band.GetOffset() == -0.1
assert band.GetScale() == 0.0001
assert band.GetMetadata_Dict("IMAGERY") == {
"CENTRAL_WAVELENGTH_UM": "0.783",
"FWHM_UM": "0.028",
}
9 changes: 8 additions & 1 deletion doc/source/drivers/raster/gti.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ driver with the following main differences:
* Contrary to the VRT driver, the GTI driver does not enable to alter
characteristics of referenced tiles, such as their georeferencing, nodata value,
etc. If such behavior is desired, the tiles must be for example wrapped
individually in a VRT file before being referenced in the GTI index.
individually in a VRT file (or `vrt://` connection string) before being referenced
in the GTI index.

Connection strings
------------------
Expand Down Expand Up @@ -443,6 +444,12 @@ also defined as layer metadata items or in the .gti XML file

Resolution along Y axis in SRS units / pixel.

- .. oo:: SRS
:choices: <string>

Override/sets the Spatial Reference System in one of the formats supported
by :cpp:func:`OGRSpatialReference::SetFromUserInput`.

- .. oo:: MINX
:choices: <float>

Expand Down
Loading

0 comments on commit c0194a1

Please sign in to comment.