Skip to content
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

Extent outside of TMS bounds #301

Open
AndrewAnnex opened this issue Jan 17, 2025 · 0 comments
Open

Extent outside of TMS bounds #301

AndrewAnnex opened this issue Jan 17, 2025 · 0 comments

Comments

@AndrewAnnex
Copy link
Contributor

I am converting a dataset of geotiffs to web-optimized COGs with rio-cogeo using a TMS defined within the planetcantile project. The dataset consists of a large number of non-COG 4x4 degree tiles spanning -180 to 180 degrees and +/- 88 latitude, and have naming convention related to the lower left point, so tile E-180_N00 spans -180 to -176 longitude and 0 to 4 degrees latitude. Each tile has a 5x5 meter per pixel resolution.

I am specifically using the custom TMS from planetcantile for the IAU projection IAU_2015:49910 (https://www.opengis.net/def/crs/IAU/2015/49910, https://spatialreference.org/ref/iau_2015/49910/) that pyproj supports as well as recent rasterio releases.

The left-side boundary easting is -10669445.554195119, this will be important in a few more sentences...

Each raw TIF file is around 2 Gb in size, so I was surprised when a few COGs processed with rio-cogeo produced COGs that were only a few hundred Kb in size.

Specifically it was all of the tiles with a origin point on the antimeridian (-180 degrees longitude) except for the "center" tile on the equator (E-180_N00).

After inspecting the metadata on these tiles, it appears that it is a floating precision issue with the origin point X point. The origin easting for the E-180_N00 tile is -10669445.554197242483497 while the next tile above it at E-180_N04 has an origin of -10669445.554209999740124. The N04 tif also ends up wrapping all the way over to +180 degrees east, so although both origins are technically outside of the projection's extent, it seems that the E-180_N04 origin is large enough to be a problem.

While I will probably go through the exercise of using gdal_edit.py to modify the source Tif files to fix this (and I have already observed this fixing the issue of the resulting COG from rio cogeo, I wonder if there is a simple fix in rio-cogeo to make to avoid this extra step?

I would expect this to have something to do with the WarpedVRT usage and the lack of boundless reading, and I saw a related PR in rio-tiler that maybe could inspire a fix, but I haven't dug into this deeply enough to know for sure.

I made faux files for the inputs and outputs from rio-cogeo with the _tms.tif postfix, and the source files are prefixed by c_. Below are the info's for the COG outputs that shows that the N04 tif has a width that doesn't make sense and world spanning extent.

faux_E-180_N00_tms.tif info:

Driver: GTiff
File: /scratch/aannex/antimeridian_issue/faux_E-180_N00_tms.tif
COG: True
Compression: ZSTD
ColorSpace: None

Profile
    Width:            46848
    Height:           46848
    Bands:            1
    Tiled:            True
    Dtype:            uint8
    NoData:           0.0
    Alpha Band:       False
    Internal Mask:    False
    Interleave:       BAND
    ColorMap:         False
    ColorInterp:      ('gray',)
    Scales:           (1.0,)
    Offsets:          (0.0,)

Geo
    Crs:              PROJCS["Mars (2015) - Sphere / Equidistant Cylindrical",GEOGCS["Mars (2015) - Sphere",DATUM["Mars (2015) - Sphere",SPHEROID["Mars (2015) - Sphere",3396190,0]],PRIMEM["Reference Meridian",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]]],PROJECTION["Equirectangular"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]
    Origin:           (-10669445.554195119, 238343.3271994274)
    Resolution:       (5.087588097665367, -5.087588097665367)
    BoundingBox:      (-10669445.554195119, 3.2014213502407074e-10, -10431102.226995692, 238343.3271994274)
    MinZoom:          None
    MaxZoom:          None

Image Metadata
    AREA_OR_POINT: Area

Image Structure
    LAYOUT: COG
    COMPRESSION: ZSTD
    INTERLEAVE: BAND

Band 1
    ColorInterp: gray

IFD
    Id      Size           BlockSize     Decimation           
    0       46848x46848    256x256       0
    1       23424x23424    256x256       2
    2       11712x11712    256x256       4
    3       5856x5856      256x256       8
    4       2928x2928      256x256       16
    5       1464x1464      256x256       32
    6       732x732        256x256       64
    7       366x366        256x256       128
    8       183x183        256x256       256

faux_E-180_N04_tms.tif info:

Driver: GTiff
File: /scratch/aannex/antimeridian_issue/faux_E-180_N04_tms.tif
COG: True
Compression: ZSTD
ColorSpace: None

Profile
    Width:            65536
    Height:           1024
    Bands:            1
    Tiled:            True
    Dtype:            uint8
    NoData:           0.0
    Alpha Band:       False
    Internal Mask:    False
    Interleave:       BAND
    ColorMap:         False
    ColorInterp:      ('gray',)
    Scales:           (1.0,)
    Offsets:          (0.0,)

Geo
    Crs:              PROJCS["Mars (2015) - Sphere / Equidistant Cylindrical",GEOGCS["Mars (2015) - Sphere",DATUM["Mars (2015) - Sphere",SPHEROID["Mars (2015) - Sphere",3396190,0]],PRIMEM["Reference Meridian",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]]],PROJECTION["Equirectangular"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]
    Origin:           (-10669445.554195119, 500130.2603528965)
    Resolution:       (325.60563825058347, -325.60563825058347)
    BoundingBox:      (-10669445.554195119, 166710.08678429906, 10669445.554195119, 500130.2603528965)
    MinZoom:          None
    MaxZoom:          None

Image Metadata
    AREA_OR_POINT: Area

Image Structure
    LAYOUT: COG
    COMPRESSION: ZSTD
    INTERLEAVE: BAND

Band 1
    ColorInterp: gray

IFD
    Id      Size           BlockSize     Decimation           
    0       65536x1024     256x256       0
    1       32768x512      256x256       2
    2       16384x256      256x256       4

faux_src.zip

faux_tms.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant