Open-EO / openeo-web-editor

An interactive and easy to use web-based editor for the OpenEO API.
https://editor.openeo.org
Apache License 2.0
12 stars 17 forks source link

geotiff viewer works if data has (10,-10) resolution but not if (10,10) #280

Closed clausmichele closed 3 weeks ago

clausmichele commented 1 year ago

I guess this is a bug. When using the Eurac back-end, the result of this graph is showed correctly:

{
  "parameters": [],
  "process_graph": {
    "apply1": {
      "process_id": "apply",
      "arguments": {
        "process": {
          "process_graph": {
            "linearscalerange1": {
              "result": true,
              "process_id": "linear_scale_range",
              "arguments": {
                "inputMax": 2500,
                "inputMin": 0,
                "x": {
                  "from_parameter": "x"
                },
                "outputMax": 255
              }
            }
          }
        },
        "data": {
          "from_node": "reducedimension2"
        }
      }
    },
    "loadcollection1": {
      "process_id": "load_collection",
      "arguments": {
        "temporal_extent": [
          "2017-07-01T00:00:00Z",
          "2017-07-31T23:59:59Z"
        ],
        "spatial_extent": {
          "east": 11.369805822041744,
          "south": 46.48845353041921,
          "north": 46.50385828131181,
          "west": 11.318964117236685
        },
        "id": "S2_L2A_T32TPS",
        "bands": [
          "B04_10m",
          "B03_10m",
          "B02_10m"
        ]
      }
    },
    "reducedimension2": {
      "process_id": "reduce_dimension",
      "arguments": {
        "data": {
          "from_node": "loadcollection1"
        },
        "reducer": {
          "process_graph": {
            "min1": {
              "result": true,
              "process_id": "min",
              "arguments": {
                "data": {
                  "from_parameter": "data"
                }
              }
            }
          }
        },
        "dimension": "t"
      }
    },
    "saveresult1": {
      "result": true,
      "process_id": "save_result",
      "arguments": {
        "data": {
          "from_node": "apply1"
        },
        "format": "GTIFF"
      }
    }
  }
}

this instead, where the result comes from a different collection, shows just a black box. The difference between the two geotiffs is the resolution, which on the not working one is (10,10) instead of (10,-10).

{
  "parameters": [],
  "process_graph": {
    "apply1": {
      "process_id": "apply",
      "arguments": {
        "process": {
          "process_graph": {
            "linearscalerange1": {
              "result": true,
              "process_id": "linear_scale_range",
              "arguments": {
                "inputMax": 2500,
                "inputMin": 0,
                "x": {
                  "from_parameter": "x"
                },
                "outputMax": 255
              }
            }
          }
        },
        "data": {
          "from_node": "reducedimension2"
        }
      }
    },
    "loadcollection1": {
      "process_id": "load_collection",
      "arguments": {
        "temporal_extent": [
          "2017-07-01T00:00:00Z",
          "2017-07-31T23:59:59Z"
        ],
        "spatial_extent": {
          "east": 11.369805822041744,
          "south": 46.48845353041921,
          "north": 46.50385828131181,
          "west": 11.318964117236685
        },
        "id": "S2_L2A_ALPS",
        "bands": [
          "B04",
          "B03",
          "B02"
        ]
      }
    },
    "reducedimension2": {
      "process_id": "reduce_dimension",
      "arguments": {
        "data": {
          "from_node": "loadcollection1"
        },
        "reducer": {
          "process_graph": {
            "min1": {
              "result": true,
              "process_id": "min",
              "arguments": {
                "data": {
                  "from_parameter": "data"
                }
              }
            }
          }
        },
        "dimension": "t"
      }
    },
    "saveresult1": {
      "result": true,
      "process_id": "save_result",
      "arguments": {
        "data": {
          "from_node": "apply1"
        },
        "format": "GTIFF"
      }
    }
  }
}

Fixing the collection resolution solves the issue, but I wonder if it shouldn't cause a problem in the viewer.

clausmichele commented 1 year ago

In the meanwhile I applied a workaround, to make sure that the y dimension has decreasing values and therefore negative resolution: https://github.com/SARScripts/openeo_odc_driver/commit/d865cfb177828ad88cc26b75f4de7232b195efeb Now it works fine on our back-end, but maybe we should still address this issue.

m-mohr commented 1 year ago

Thanks Michele. Can you send me an example file for testing purposes? I assume this is an upstream issue in OL or geotiff.js and I'll need to provide an example if I open an issue with them.

clausmichele commented 1 year ago

Sure! Not working: image Working: image tiff_samples.zip

m-mohr commented 1 year ago

@clausmichele I've just tested this in pure OpenLayers and it also doesn't work there so this is an upstream issue. I'm just wondering what does a negative resolution mean? Is that valid? Anyway, this is something to report to the openlayers guys...

clausmichele commented 1 year ago

In this case the positive resolution for y is the issue. Anyway, most of the time there is a positive resolution along x and a negative along y. However, a geoTIFF can contain theoretically any combination of them.

m-mohr commented 1 year ago

Okay, I've submitted a bug report: https://github.com/openlayers/openlayers/issues/14238

m-mohr commented 1 year ago

Looks like a bug in geotiff.js: https://github.com/geotiffjs/geotiff.js/pull/337