geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
484 stars 258 forks source link

EDR Xarray covjson reordering y #1780

Open pzaborowski opened 1 month ago

pzaborowski commented 1 month ago

Description in provider/xarray_.py gen_covjson function following code:

minx, miny, maxx, maxy = metadata['bbox']
        mint, maxt = metadata['time']
        try:
            tmp_min = data.coords[self.y_field].values[0]
        except IndexError:
            tmp_min = data.coords[self.y_field].values
        try:
            tmp_max = data.coords[self.y_field].values[-1]
        except IndexError:
            tmp_max = data.coords[self.y_field].values

        if tmp_min > tmp_max:
            LOGGER.debug(f'Reversing direction of {self.y_field}')
            miny = tmp_max
            maxy = tmp_min
...
                    'y': {
                        'start': maxy,
                        'stop': miny,

Is reversing only axis north-south but not data. It breaks resulting coveragejson with inconsistent axis-data. Either it shall be followed by the data reordering (not cheap so maybe not recommended) or axis start/stop shall be read from data. Reading start/stop from data would also partly address the issue when data grid does not fill the query bbox and resulting array would not fill current axis. Steps to Reproduce Steps to reproduce the behavior: Use reference configuration from https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-edr.html View the results on the map - see it is upside down.

Expected behavior

  1. Reordering of axis shall be removed or followed by data reordering - in case data is not expected organisation exception could be rised optionally.
  2. start/stop of axis shall be read from data to make it consistent with variables (not bbox min/max which could make data stretched inproperly

Screenshots/Tracebacks If applicable, add screenshots to help explain your problem.

Environment

Additional context Test data from https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-edr.html

pzaborowski commented 1 week ago

same problem in demo deployment https://demo.pygeoapi.io/master/collections/icoads-sst/cube?bbox=-180,-90,180,90&datetime=2000-01-16%2F2000-02-01&select_properties=AIRT

image