Skip to content

gdalwarp odd antimeridian handling #11400

@Plantain

Description

@Plantain

What is the bug?

I have a space-projected GeoTIFF that spans the antimeridian - ( http://static.skysight.io/raw.tiff )

I want to transform it to EPSG:3857, and clip only a square from the "middle" of the data by defining extents that cross the antimeridian. I am not sure yet if it matters if the resulting image wraps or not, whether it could be 0-360 or must be -180 to 180, the result will have overviews generated and be used for tile serving. I am trying to avoid approaches that might lose fidelity or add processing time as this is to be done in realtime.

The image looks something like this:
Screenshot 2024-12-01 at 11 29 13 am
And I want to extract the middle:
Screenshot 2024-12-01 at 11 29 32 am

I tried several approaches, and I am not sure if I am bouncing off bugs, undefined behaviour, or my own incompetence.

Steps to reproduce the issue

Firstly, warping to
gdalwarp -of PNG -t_srs EPSG:3857 raw.tiff out.png
Works as expected
Screenshot 2024-12-01 at 11 11 17 am

Attempting to crop using extents beyond -180 crashes, I guess to be expected:
gdalwarp -of PNG -t_srs EPSG:3857 raw.tiff out.png -te_srs EPSG:4326 -190 -65 -90 70
ERROR 1: Invalid dfWestLongitudeDeg
Creating output file that is -39965P x 28552L.
ERROR 1: Attempt to create -39965x28552 dataset is illegal,sizes must be larger than zero.

Interesting, the same in EPSG:3857 coordinates does run! But the result is missing everything west of the antimeridian
gdalwarp -of PNG -t_srs EPSG:3857 raw.tiff out.png -te -22094105.797 -11068715.659 -10018754.171 11068715.659
ERROR 1: Point outside of projection domain
Creating output file that is 23198P x 42528L.
Screenshot 2024-12-01 at 11 16 04 am

I then tried to get clever and specify +over explicitly on the projection, but get the same result, missing everything west of the antimeridian:
gdalwarp -of PNG -t_srs '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over' -te -22094105.797 -11068715.659 -10018754.171 11068715.659 raw.tiff over.png
Screenshot 2024-12-01 at 11 20 35 am

Trying with CENTER_LONG seems to have no effect
gdalwarp -of PNG -t_srs 'EPSG:3857' --config CENTER_LONG 180 raw.tiff over.png
Screenshot 2024-12-01 at 11 08 51 am

Unless I change the projection to EPSG:4326, in which case there's nothing east of the antimeridian??
gdalwarp -of PNG -t_srs 'EPSG:4326' --config CENTER_LONG 180 raw.tiff over.png
Screenshot 2024-12-01 at 11 22 44 am

Versions and provenance

GDAL 3.10.0, released 2024/11/01
OSX via Brew

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions