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

Use negative pixel sizes / switch origins #52

Open
whisperingpixel opened this issue Jun 5, 2024 · 0 comments
Open

Use negative pixel sizes / switch origins #52

whisperingpixel opened this issue Jun 5, 2024 · 0 comments
Labels
feature 🎁 New feature or request

Comments

@whisperingpixel
Copy link
Contributor

Description

In the output the pixel sizes are positive Pixel Size = (10.000000000000000,10.000000000000000).

However, this creates some problems with various gdal tools, e.g., creatinge VRTs or Mosaics:

gdalbuildvrt: Warning 1: gdalbuildvrt does not support positive NS resolution. Skipping <filename>
gdal_merge.py:

Traceback (most recent call last):
  File "/usr/bin/gdal_merge.py", line 14, in <module>
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/osgeo_utils/gdal_merge.py", line 650, in main
    return gdal_merge(argv)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/osgeo_utils/gdal_merge.py", line 572, in gdal_merge
    t_fh = driver.Create(out_file, xsize, ysize, bands, band_type, create_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 3742, in Create
    return _gdal.Driver_Create(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Attempt to create 10000x-17999 dataset is illegal,sizes must be larger than zero.

Full GDAL-Info on an output file

Driver: GTiff/GeoTIFF
Files: masked_curve_id69785.tiff
Size is 437, 386
Coordinate System is:
PROJCRS["ETRS89-extended / LAEA Europe",
    BASEGEOGCRS["ETRS89",
        ENSEMBLE["European Terrestrial Reference System 1989 ensemble",
            MEMBER["European Terrestrial Reference Frame 1989"],
            MEMBER["European Terrestrial Reference Frame 1990"],
            MEMBER["European Terrestrial Reference Frame 1991"],
            MEMBER["European Terrestrial Reference Frame 1992"],
            MEMBER["European Terrestrial Reference Frame 1993"],
            MEMBER["European Terrestrial Reference Frame 1994"],
            MEMBER["European Terrestrial Reference Frame 1996"],
            MEMBER["European Terrestrial Reference Frame 1997"],
            MEMBER["European Terrestrial Reference Frame 2000"],
            MEMBER["European Terrestrial Reference Frame 2005"],
            MEMBER["European Terrestrial Reference Frame 2014"],
            MEMBER["European Terrestrial Reference Frame 2020"],
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]],
            ENSEMBLEACCURACY[0.1]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4258]],
    CONVERSION["Europe Equal Area 2001",
        METHOD["Lambert Azimuthal Equal Area",
            ID["EPSG",9820]],
        PARAMETER["Latitude of natural origin",52,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",10,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["False easting",4321000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",3210000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["northing (Y)",north,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["easting (X)",east,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Statistical analysis."],
        AREA["Europe - European Union (EU) countries and candidates. Europe - onshore and offshore: Albania; Andorra; Austria; Belgium; Bosnia and Herzegovina; Bulgaria; Croatia; Cyprus; Czechia; Denmark; Estonia; Faroe Islands; Finland; France; Germany; Gibraltar; Greece; Hungary; Iceland; Ireland; Italy; Kosovo; Latvia; Liechtenstein; Lithuania; Luxembourg; Malta; Monaco; Montenegro; Netherlands; North Macedonia; Norway including Svalbard and Jan Mayen; Poland; Portugal including Madeira and Azores; Romania; San Marino; Serbia; Slovakia; Slovenia; Spain including Canary Islands; Sweden; Switzerland; Türkiye (Turkey); United Kingdom (UK) including Channel Islands and Isle of Man; Vatican City State."],
        BBOX[24.6,-35.58,84.73,44.83]],
    ID["EPSG",3035]]
Data axis to CRS axis mapping: 2,1
Origin = (4549180.000000000000000,2746020.000000000000000)
Pixel Size = (10.000000000000000,10.000000000000000)
Metadata:
  value_type=continuous
  AREA_OR_POINT=Area
Image Structure Metadata:
  LAYOUT=COG
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 4549180.000, 2746020.000) ( 13d 2'39.28"E, 47d47' 7.87"N)
Lower Left  ( 4549180.000, 2749880.000) ( 13d 2'46.70"E, 47d49'12.80"N)
Upper Right ( 4553550.000, 2746020.000) ( 13d 6' 8.95"E, 47d47' 1.98"N)
Lower Right ( 4553550.000, 2749880.000) ( 13d 6'16.51"E, 47d49' 6.91"N)
Center      ( 4551365.000, 2747950.000) ( 13d 4'27.86"E, 47d48' 7.40"N)
Band 1 Block=512x512 Type=Float64, ColorInterp=Gray
  Description = masked_curve

This is not the case in the input images, where the origins are different and the pixel sizes are negative. Example: Full GDAL-Info on a SIAM-Processed file (notice the negative pixel size):

info T33UXP_20210301T100031_calrefbyt_lndstlk_SIAMCr_33SharedSpCt_r88v7.tiff
Driver: GTiff/GeoTIFF
Files: T33UXP_20210301T100031_calrefbyt_lndstlk_SIAMCr_33SharedSpCt_r88v7.tiff
       T33UXP_20210301T100031_calrefbyt_lndstlk_SIAMCr_33SharedSpCt_r88v7.tiff.aux.xml
Size is 11683, 11717
Coordinate System is:
PROJCRS["ETRS89-extended / LAEA Europe",
    BASEGEOGCRS["ETRS89",
        ENSEMBLE["European Terrestrial Reference System 1989 ensemble",
            MEMBER["European Terrestrial Reference Frame 1989"],
            MEMBER["European Terrestrial Reference Frame 1990"],
            MEMBER["European Terrestrial Reference Frame 1991"],
            MEMBER["European Terrestrial Reference Frame 1992"],
            MEMBER["European Terrestrial Reference Frame 1993"],
            MEMBER["European Terrestrial Reference Frame 1994"],
            MEMBER["European Terrestrial Reference Frame 1996"],
            MEMBER["European Terrestrial Reference Frame 1997"],
            MEMBER["European Terrestrial Reference Frame 2000"],
            MEMBER["European Terrestrial Reference Frame 2005"],
            MEMBER["European Terrestrial Reference Frame 2014"],
            MEMBER["European Terrestrial Reference Frame 2020"],
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]],
            ENSEMBLEACCURACY[0.1]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4258]],
    CONVERSION["Europe Equal Area 2001",
        METHOD["Lambert Azimuthal Equal Area",
            ID["EPSG",9820]],
        PARAMETER["Latitude of natural origin",52,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",10,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["False easting",4321000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",3210000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["northing (Y)",north,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["easting (X)",east,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Statistical analysis."],
        AREA["Europe - European Union (EU) countries and candidates. Europe - onshore and offshore: Albania; Andorra; Austria; Belgium; Bosnia and Herzegovina; Bulgaria; Croatia; Cyprus; Czechia; Denmark; Estonia; Faroe Islands; Finland; France; Germany; Gibraltar; Greece; Hungary; Iceland; Ireland; Italy; Kosovo; Latvia; Liechtenstein; Lithuania; Luxembourg; Malta; Monaco; Montenegro; Netherlands; North Macedonia; Norway including Svalbard and Jan Mayen; Poland; Portugal including Madeira and Azores; Romania; San Marino; Serbia; Slovakia; Slovenia; Spain including Canary Islands; Sweden; Switzerland; Türkiye (Turkey); United Kingdom (UK) including Channel Islands and Isle of Man; Vatican City State."],
        BBOX[24.6,-35.58,84.73,44.83]],
    ID["EPSG",3035]]
Data axis to CRS axis mapping: 2,1
Origin = (4788250.000000000000000,2875700.000000000000000)
Pixel Size = (10.000000000000000,-10.000000000000000)
Metadata:
  Band_1=Spectral Categories
  AREA_OR_POINT=Area
Image Structure Metadata:
  LAYOUT=COG
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 4788250.000, 2875700.000) ( 16d22' 7.91"E, 48d48'45.74"N)
Lower Left  ( 4788250.000, 2758530.000) ( 16d14'14.95"E, 47d45'46.45"N)
Upper Right ( 4905080.000, 2875700.000) ( 17d57' 4.96"E, 48d42'38.60"N)
Lower Right ( 4905080.000, 2758530.000) ( 17d47'16.51"E, 47d39'47.99"N)
Center      ( 4846665.000, 2817115.000) ( 17d 5'10.14"E, 48d14'25.03"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Palette
  Description = Spectral Categories
  Overviews: 5841x5858, 2920x2929, 1460x1464, 730x732, 365x366
  Categories:
      0: Unclassified
      1: SVHNIR
      2: SVLNIR
      3: AVHNIR
      4: AVLNIR
      5: WV
      6: VSH_VWA_TWASH
      7: SHRBRHNIR
      8: SHRBRLNIR
      9: HRBCR
     10: WR
     11: PB
     12: GH
     13: VBBB
     14: BBB
     15: SBB
     16: ABB
     17: DBB
     18: WBBorBBSH
     19: NIRPBB
     20: BA
     21: DPWASH
     22: SLWASH
     23: TWASH
     24: SASLWA
     25: CL
     26: SMKPLM
     27: TNCLV
     28: TNCLWA_BB
     29: SN_WAICE
     30: SHSN
     31: SH
     32: FLAME
     33: UN
     34: ERROR
     35: ERROR
     36: ERROR
     37: ERROR
     38: ERROR
     39: ERROR
     40: ERROR
     41: ERROR
     42: ERROR
     43: ERROR
     44: ERROR
     45: ERROR
     46: ERROR
     47: ERROR
     48: ERROR
     49: ERROR
     50: ERROR
     51: ERROR
     52: ERROR
     53: ERROR
     54: ERROR
     55: ERROR
     56: ERROR
     57: ERROR
     58: ERROR
     59: ERROR
     60: ERROR
     61: ERROR
     62: ERROR
     63: ERROR
     64: ERROR
     65: ERROR
     66: ERROR
     67: ERROR
     68: ERROR
     69: ERROR
     70: ERROR
     71: ERROR
     72: ERROR
     73: ERROR
     74: ERROR
     75: ERROR
     76: ERROR
     77: ERROR
     78: ERROR
     79: ERROR
     80: ERROR
     81: ERROR
     82: ERROR
     83: ERROR
     84: ERROR
     85: ERROR
     86: ERROR
     87: ERROR
     88: ERROR
     89: ERROR
     90: ERROR
     91: ERROR
     92: ERROR
     93: ERROR
     94: ERROR
     95: ERROR
     96: ERROR
     97: ERROR
     98: ERROR
     99: ERROR
    100: ERROR
    101: ERROR
    102: ERROR
    103: ERROR
    104: ERROR
    105: ERROR
    106: ERROR
    107: ERROR
    108: ERROR
    109: ERROR
    110: ERROR
    111: ERROR
    112: ERROR
    113: ERROR
    114: ERROR
    115: ERROR
    116: ERROR
    117: ERROR
    118: ERROR
    119: ERROR
    120: ERROR
    121: ERROR
    122: ERROR
    123: ERROR
    124: ERROR
    125: ERROR
    126: ERROR
    127: ERROR
    128: ERROR
    129: ERROR
    130: ERROR
    131: ERROR
    132: ERROR
    133: ERROR
    134: ERROR
    135: ERROR
    136: ERROR
    137: ERROR
    138: ERROR
    139: ERROR
    140: ERROR
    141: ERROR
    142: ERROR
    143: ERROR
    144: ERROR
    145: ERROR
    146: ERROR
    147: ERROR
    148: ERROR
    149: ERROR
    150: ERROR
    151: ERROR
    152: ERROR
    153: ERROR
    154: ERROR
    155: ERROR
    156: ERROR
    157: ERROR
    158: ERROR
    159: ERROR
    160: ERROR
    161: ERROR
    162: ERROR
    163: ERROR
    164: ERROR
    165: ERROR
    166: ERROR
    167: ERROR
    168: ERROR
    169: ERROR
    170: ERROR
    171: ERROR
    172: ERROR
    173: ERROR
    174: ERROR
    175: ERROR
    176: ERROR
    177: ERROR
    178: ERROR
    179: ERROR
    180: ERROR
    181: ERROR
    182: ERROR
    183: ERROR
    184: ERROR
    185: ERROR
    186: ERROR
    187: ERROR
    188: ERROR
    189: ERROR
    190: ERROR
    191: ERROR
    192: ERROR
    193: ERROR
    194: ERROR
    195: ERROR
    196: ERROR
    197: ERROR
    198: ERROR
    199: ERROR
    200: ERROR
    201: ERROR
    202: ERROR
    203: ERROR
    204: ERROR
    205: ERROR
    206: ERROR
    207: ERROR
    208: ERROR
    209: ERROR
    210: ERROR
    211: ERROR
    212: ERROR
    213: ERROR
    214: ERROR
    215: ERROR
    216: ERROR
    217: ERROR
    218: ERROR
    219: ERROR
    220: ERROR
    221: ERROR
    222: ERROR
    223: ERROR
    224: ERROR
    225: ERROR
    226: ERROR
    227: ERROR
    228: ERROR
    229: ERROR
    230: ERROR
    231: ERROR
    232: ERROR
    233: ERROR
    234: ERROR
    235: ERROR
    236: ERROR
    237: ERROR
    238: ERROR
    239: ERROR
    240: ERROR
    241: ERROR
    242: ERROR
    243: ERROR
    244: ERROR
    245: ERROR
    246: ERROR
    247: ERROR
    248: ERROR
    249: ERROR
    250: ERROR
    251: ERROR
    252: ERROR
    253: ERROR
    254: ERROR
    255: MASKED_NO_DATA
  Color Table (RGB with 256 entries)
    0: 0,0,0,255
    1: 30,250,30,255
    2: 20,175,20,255
    3: 0,220,90,255
    4: 0,170,110,255
    5: 175,250,140,255
    6: 100,120,80,255
    7: 190,250,160,255
    8: 140,170,110,255
    9: 225,250,50,255
   10: 200,200,100,255
   11: 100,130,120,255
   12: 175,255,255,255
   13: 255,170,110,255
   14: 230,155,95,255
   15: 210,140,100,255
   16: 180,100,70,255
   17: 140,60,50,255
   18: 230,130,60,255
   19: 190,190,220,255
   20: 130,50,80,255
   21: 0,0,80,255
   22: 0,40,110,255
   23: 70,100,130,255
   24: 110,0,150,255
   25: 230,230,230,255
   26: 90,70,110,255
   27: 200,225,175,255
   28: 190,190,245,255
   29: 30,255,255,255
   30: 0,100,140,255
   31: 20,20,60,255
   32: 255,20,70,255
   33: 255,0,0,255
   34: 0,0,0,255
   35: 0,0,0,255
   36: 0,0,0,255
   37: 0,0,0,255
   38: 0,0,0,255
   39: 0,0,0,255
   40: 0,0,0,255
   41: 0,0,0,255
   42: 0,0,0,255
   43: 0,0,0,255
   44: 0,0,0,255
   45: 0,0,0,255
   46: 0,0,0,255
   47: 0,0,0,255
   48: 0,0,0,255
   49: 0,0,0,255
   50: 0,0,0,255
   51: 0,0,0,255
   52: 0,0,0,255
   53: 0,0,0,255
   54: 0,0,0,255
   55: 0,0,0,255
   56: 0,0,0,255
   57: 0,0,0,255
   58: 0,0,0,255
   59: 0,0,0,255
   60: 0,0,0,255
   61: 0,0,0,255
   62: 0,0,0,255
   63: 0,0,0,255
   64: 0,0,0,255
   65: 0,0,0,255
   66: 0,0,0,255
   67: 0,0,0,255
   68: 0,0,0,255
   69: 0,0,0,255
   70: 0,0,0,255
   71: 0,0,0,255
   72: 0,0,0,255
   73: 0,0,0,255
   74: 0,0,0,255
   75: 0,0,0,255
   76: 0,0,0,255
   77: 0,0,0,255
   78: 0,0,0,255
   79: 0,0,0,255
   80: 0,0,0,255
   81: 0,0,0,255
   82: 0,0,0,255
   83: 0,0,0,255
   84: 0,0,0,255
   85: 0,0,0,255
   86: 0,0,0,255
   87: 0,0,0,255
   88: 0,0,0,255
   89: 0,0,0,255
   90: 0,0,0,255
   91: 0,0,0,255
   92: 0,0,0,255
   93: 0,0,0,255
   94: 0,0,0,255
   95: 0,0,0,255
   96: 0,0,0,255
   97: 0,0,0,255
   98: 0,0,0,255
   99: 0,0,0,255
  100: 0,0,0,255
  101: 0,0,0,255
  102: 0,0,0,255
  103: 0,0,0,255
  104: 0,0,0,255
  105: 0,0,0,255
  106: 0,0,0,255
  107: 0,0,0,255
  108: 0,0,0,255
  109: 0,0,0,255
  110: 0,0,0,255
  111: 0,0,0,255
  112: 0,0,0,255
  113: 0,0,0,255
  114: 0,0,0,255
  115: 0,0,0,255
  116: 0,0,0,255
  117: 0,0,0,255
  118: 0,0,0,255
  119: 0,0,0,255
  120: 0,0,0,255
  121: 0,0,0,255
  122: 0,0,0,255
  123: 0,0,0,255
  124: 0,0,0,255
  125: 0,0,0,255
  126: 0,0,0,255
  127: 0,0,0,255
  128: 0,0,0,255
  129: 0,0,0,255
  130: 0,0,0,255
  131: 0,0,0,255
  132: 0,0,0,255
  133: 0,0,0,255
  134: 0,0,0,255
  135: 0,0,0,255
  136: 0,0,0,255
  137: 0,0,0,255
  138: 0,0,0,255
  139: 0,0,0,255
  140: 0,0,0,255
  141: 0,0,0,255
  142: 0,0,0,255
  143: 0,0,0,255
  144: 0,0,0,255
  145: 0,0,0,255
  146: 0,0,0,255
  147: 0,0,0,255
  148: 0,0,0,255
  149: 0,0,0,255
  150: 0,0,0,255
  151: 0,0,0,255
  152: 0,0,0,255
  153: 0,0,0,255
  154: 0,0,0,255
  155: 0,0,0,255
  156: 0,0,0,255
  157: 0,0,0,255
  158: 0,0,0,255
  159: 0,0,0,255
  160: 0,0,0,255
  161: 0,0,0,255
  162: 0,0,0,255
  163: 0,0,0,255
  164: 0,0,0,255
  165: 0,0,0,255
  166: 0,0,0,255
  167: 0,0,0,255
  168: 0,0,0,255
  169: 0,0,0,255
  170: 0,0,0,255
  171: 0,0,0,255
  172: 0,0,0,255
  173: 0,0,0,255
  174: 0,0,0,255
  175: 0,0,0,255
  176: 0,0,0,255
  177: 0,0,0,255
  178: 0,0,0,255
  179: 0,0,0,255
  180: 0,0,0,255
  181: 0,0,0,255
  182: 0,0,0,255
  183: 0,0,0,255
  184: 0,0,0,255
  185: 0,0,0,255
  186: 0,0,0,255
  187: 0,0,0,255
  188: 0,0,0,255
  189: 0,0,0,255
  190: 0,0,0,255
  191: 0,0,0,255
  192: 0,0,0,255
  193: 0,0,0,255
  194: 0,0,0,255
  195: 0,0,0,255
  196: 0,0,0,255
  197: 0,0,0,255
  198: 0,0,0,255
  199: 0,0,0,255
  200: 0,0,0,255
  201: 0,0,0,255
  202: 0,0,0,255
  203: 0,0,0,255
  204: 0,0,0,255
  205: 0,0,0,255
  206: 0,0,0,255
  207: 0,0,0,255
  208: 0,0,0,255
  209: 0,0,0,255
  210: 0,0,0,255
  211: 0,0,0,255
  212: 0,0,0,255
  213: 0,0,0,255
  214: 0,0,0,255
  215: 0,0,0,255
  216: 0,0,0,255
  217: 0,0,0,255
  218: 0,0,0,255
  219: 0,0,0,255
  220: 0,0,0,255
  221: 0,0,0,255
  222: 0,0,0,255
  223: 0,0,0,255
  224: 0,0,0,255
  225: 0,0,0,255
  226: 0,0,0,255
  227: 0,0,0,255
  228: 0,0,0,255
  229: 0,0,0,255
  230: 0,0,0,255
  231: 0,0,0,255
  232: 0,0,0,255
  233: 0,0,0,255
  234: 0,0,0,255
  235: 0,0,0,255
  236: 0,0,0,255
  237: 0,0,0,255
  238: 0,0,0,255
  239: 0,0,0,255
  240: 0,0,0,255
  241: 0,0,0,255
  242: 0,0,0,255
  243: 0,0,0,255
  244: 0,0,0,255
  245: 0,0,0,255
  246: 0,0,0,255
  247: 0,0,0,255
  248: 0,0,0,255
  249: 0,0,0,255
  250: 0,0,0,255
  251: 0,0,0,255
  252: 0,0,0,255
  253: 0,0,0,255
  254: 0,0,0,255
  255: 255,255,255,255

Additional context

This is not really a but since it is not wrong per se, but the input/output should be consistent in my opinion.

References https://github.com/Sen2Cube-at/sen2cube.at/issues/848

@whisperingpixel whisperingpixel added the feature 🎁 New feature or request label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎁 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant