Skip to content

Invalid VRT Size when converting from EPSG:4326 to EPSG:3857 #8730

Description

@vincentsarago

ref: cogeotiff/rio-tiler#654

Expected behavior and actual behavior.

I've got a file which span the entire world (in epsg:4326, -180 90 180 -90), when building a VRT in EPSG:3857 the result size seems wrong.

I'm pretty sure this is because the bounds over flows the area of use of the EPSG:3857 projection.

gdalwarp -of VRT -t_srs epsg:3857 world_cog.tif world_cog.vrt
Creating output file that is 66P x 802L.

The Y size (802) seems ok but the X (66) is definitely wrong.

When I use dataset which doesn't cross the area of use everything is fine!

gdal_create -of COG -outsize 720 360 -a_srs EPSG:4326 -a_ullr -175 85 175 -85 world_cog.tif 
0...10...20...30...40...50...60...70...80...90...100 - done.

gdalwarp -of VRT -t_srs epsg:3857 world_cog.tif world_cog.vrt -overwrite
Creating output file that is 562P x 576L.
Processing world_cog.tif [1/1] : 0...10...20...30...40...50...60...70...80...90...100 - done.

I'm not sure exactly if the issue in either in proj or in GDAL and if anything is possible 🤷

Steps to reproduce the problem.

gdal_create -of COG -outsize 720 360 -a_srs EPSG:4326 -a_ullr -180 90 180 -90 world_cog.tif 
0...10...20...30...40...50...60...70...80...90...100 - done.

gdalwarp -of VRT -t_srs epsg:3857 world_cog.tif world_cog.vrt
Creating output file that is 66P x 802L.
Processing world_cog.tif [1/1] : 0...10...20...30...40...50...60...70...80...90...100 - done.

gdalinfo world_cog.vrt
Driver: VRT/Virtual Raster
Files: world_cog.vrt
       world_cog.tif
Size is 66, 802
Coordinate System is:
PROJCRS["WGS 84 / Pseudo-Mercator",
    BASEGEOGCRS["WGS 84",
        DATUM["World Geodetic System 1984",
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4326]],
    CONVERSION["unnamed",
        METHOD["Popular Visualisation Pseudo Mercator",
            ID["EPSG",1024]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["False easting",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["easting",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    ID["EPSG",3857]]
Data axis to CRS axis mapping: 1,2
Origin = (-20037508.342789243906736,242528680.943742722272873)
Pixel Size = (604620.393207252956927,-604620.393207252956927)
Metadata:
  AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (-20037508.343,242528680.944) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left  (-20037508.343,-242376874.408) (180d 0' 0.00"W, 90d 0' 0.00"S)
Upper Right (19867437.609,242528680.944) (178d28'20.02"E, 90d 0' 0.00"N)
Lower Right (19867437.609,-242376874.408) (178d28'20.02"E, 90d 0' 0.00"S)
Center      (  -85035.367,   75903.268) (  0d45'49.99"W,  0d40'54.60"N)
Band 1 Block=66x128 Type=Byte, ColorInterp=Gray
  Overviews: 33x401

Operating system

Mac OS / CentOS (AWS Lambda)

GDAL version and provenance

GDAL 3.7.2 (homebrew)
GDAL 3.8 (docker)

gdalinfo --version
GDAL 3.8.0, released 2023/11/06

Activity

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

Metadata

Metadata

Assignees

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