Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CRS parsing of GTI:index.parquet consistent with STACIT:items.json #11512

Closed
scottyhq opened this issue Dec 18, 2024 · 1 comment · Fixed by #11514
Closed

Make CRS parsing of GTI:index.parquet consistent with STACIT:items.json #11512

scottyhq opened this issue Dec 18, 2024 · 1 comment · Fixed by #11514
Assignees

Comments

@scottyhq
Copy link
Contributor

Feature description

I was expecting that STACIT and GTI drivers would recognize a STAC item's CRS in the same way, but this is currently only true if an item uses proj:epsg.

For the STAC projection extension, it's possible to specify proj:projjson and proj:wkt2 (and proj:epsg has been deprecated in favor of proj:code... I see those changes for STACIT are being worked on here #10773).

If I understand correctly, the STACIT driver chooses the CRS with the following order (1. epsg code, 2. wkt2, 3. projjson)

auto oProjEPSG = GetAssetOrFeatureProperty("proj:epsg");
std::string osProjUserString;
if (oProjEPSG.IsValid() && oProjEPSG.GetType() != CPLJSONObject::Type::Null)
{
osProjUserString = "EPSG:" + oProjEPSG.ToString();
}
else
{
auto oProjWKT2 = GetAssetOrFeatureProperty("proj:wkt2");
if (oProjWKT2.IsValid() &&
oProjWKT2.GetType() == CPLJSONObject::Type::String)
{
osProjUserString = oProjWKT2.ToString();
}
else
{
auto oProjPROJJSON = GetAssetOrFeatureProperty("proj:projjson");

But the GTI driver currently does not read projjson or wkt2:

if (bIsStacGeoParquet && !pszSRS && !pszResX && !pszResY && !pszMinX &&
!pszMinY && !pszMaxX && !pszMaxY &&
((iProjEPSG = poLayerDefn->GetFieldIndex(
CPLSPrintf("assets.%s.proj:epsg", osAssetName.c_str()))) >= 0 ||
(iProjEPSG = poLayerDefn->GetFieldIndex("proj:epsg")) >= 0) &&
((iProjTransform = poLayerDefn->GetFieldIndex(CPLSPrintf(
"assets.%s.proj:transform", osAssetName.c_str()))) >= 0 ||
(iProjTransform = poLayerDefn->GetFieldIndex("proj:transform")) >= 0))

Additional context

Here is a valid STAC item without epsg, but with wkt2:
For example, here is a STAC Item without an EPSG code:
https://landsatlook.usgs.gov/stac-server/collections/landsat-c2l2alb-sr/items/LC09_L2SP_062047_20241216_20241217_02_A1_SR

And here is a valid item with projjson:
https://raw.githubusercontent.com/uw-cryo/stv-aux-data/refs/heads/main/CO_WestCentral_2019_A19/utm12/USGS_1M_12_x76y426_CO_WestCentral_2019_A19.json

The docs are currently accurate in that the GTI driver only seems to look at proj:epsg and proj:transform, but it would be great if these similar drivers worked consistently with the CRS parsing.

It can make use of fields proj:epsg and proj:transform from the Projection Extension Specification, to correctly infer the appropriate projection and resolution.

@rouault
Copy link
Member

rouault commented Dec 18, 2024

see #11514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants