-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
gdalwarp odd antimeridian handling #11400
Comments
I think you must clip the raster into two halves.
|
I think this should not have to be the case with CENTER_LONG or lon_wrap=180? Because of some downstream decision making my tileserving speed is linearly related to the number of files I have to check. |
I don't know how you could make such single wrapping image in the target CRS, EPSG:3857. The Proj library supports wrapping only with geographic coordinate systems, not with projected ones. See https://proj.org/en/stable/usage/projections.html
|
Should either:
or
not work then? |
The projected bounds of EPSG:3857 are
I do not believe that there is any supported way to centre EPSG:3857 at any other longitude than 0, or to go beyond the bounds of the valid coordinate range. So either you must split the image into two halves, or to select some other coordinate system and create a custom tiling schema for that CRS. The two half-images can be merged into one with gdal_merge or gdalbuildvrt+gdal_translate if it is essential to have one image instead of two, but then you will have lots of nodata pixels in the middle. Note: I have never done anything with a gestatationary CRS like this and I noticed that my own commands do not really work. The CRS is |
Below are tested commands which creates two halves in EPSG:3857 which show correctly in QGIS. The images can then be converted into Web Mercator tiles according to the Google schema, if that was your final goal, The Google tiles are never split by the antimeridian so the end result will be the same from these two half-images of from a theoretical single image. Theoretical because I do not know if it is possible to create such.
By creating Cloud Optimized GeoTIFFs the overviews and tiles are generated automatically but it is slower and I do not know if you would have any benefit from COG for your use case.
I do not believe that you you have found any bug in GDAL so this issue may be closed soon. The right forum for asking questions about how to use GDAL is the gdal-dev mailing list. I know that in GitHub it is more convenient because it is easy to add screenshots etc. |
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
The text was updated successfully, but these errors were encountered: