-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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:
And I want to extract the middle:
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
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.
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
Trying with CENTER_LONG seems to have no effect
gdalwarp -of PNG -t_srs 'EPSG:3857' --config CENTER_LONG 180 raw.tiff over.png
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
Versions and provenance
GDAL 3.10.0, released 2024/11/01
OSX via Brew
Additional context
No response