Skip to content

Add gdal raster shift-longitude - #14988

Open
dbaston wants to merge 1 commit into
OSGeo:masterfrom
dbaston:shift-longitude
Open

Add gdal raster shift-longitude#14988
dbaston wants to merge 1 commit into
OSGeo:masterfrom
dbaston:shift-longitude

Conversation

@dbaston

@dbaston dbaston commented Aug 3, 2026

Copy link
Copy Markdown
Member

References #5497

@dbaston dbaston added the gdal_cli Anything related to the new 3.11 "gdal" CLI frontend label Aug 3, 2026
Comment on lines +83 to +91
{
const int nXOff = static_cast<int>(
std::ceil(std::abs(dfSrcMinX - m_minX) / srcGT.xscale) *
(m_minX < dfSrcMinX ? -1 : 1));
m_minX = dfSrcMinX + nXOff * srcGT.xscale;
}
const int nDstXSize =
static_cast<int>(std::ceil((m_maxX - m_minX) / srcGT.xscale));

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.

integer range should be checked before casting to int

dfDstChunkMinX -= 360;
}

const int nSrcXOff = static_cast<int>(

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.

no risk of overflow ?

@dbaston

dbaston commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

I noticed this comment on the referenced issue, still needs to be addressed:

"virtual" dataset (which is likely to be a VRT) returned by split-and-swap should have a GEOLOCATION metadata with X_DATASET and Y_DATASET being inline VRT doing the split-and-swap on the original X_DATASET/Y_DATASET . GCPs if present should also be edited to modify the dfPixel value . If there is RPC, I believe we can't do anything but discard it with a warning.

@mdsumner if you have an example dataset that uses geolocation arrays, I'd love to play around with it.

@mdsumner

Copy link
Copy Markdown
Contributor

maybe this one?

 gdal raster info "NETCDF:\"/vsicurl/https://dapds00.nci.org.au/thredds/fileServer/cj50/access-om2/raw-output/access-om2-01/01deg_jra55v13_ryf9091/output1032/ice/OUTPUT/iceh.2159-03.nc\":TLON" --stats
...
    STATISTICS_MINIMUM=0.00010228854807792
    STATISTICS_MAXIMUM=359.99981689453
    STATISTICS_MEAN=191.3718458503
    STATISTICS_STDDEV=101.71589302166
    STATISTICS_VALID_PERCENT=71.2

sst_m in there uses TLON/TLAT.
`

@dbaston

dbaston commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

Thanks! Interestingly, TLAT and TLON use missing_value to indicate land. That could make the split & swap a bit more tricky.

image

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

Labels

gdal_cli Anything related to the new 3.11 "gdal" CLI frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants