diff --git a/pygeoapi/provider/xarray_.py b/pygeoapi/provider/xarray_.py index 15315145f..f06bb1053 100644 --- a/pygeoapi/provider/xarray_.py +++ b/pygeoapi/provider/xarray_.py @@ -237,7 +237,7 @@ def gen_covjson(self, metadata, data, fields): :param metadata: coverage metadata :param data: rasterio DatasetReader object - :param fields: fields dict + :param fields: fields :returns: dict of CoverageJSON representation """ @@ -246,6 +246,11 @@ def gen_covjson(self, metadata, data, fields): minx, miny, maxx, maxy = metadata['bbox'] mint, maxt = metadata['time'] + selected_fields = { + key: value for key, value in self.fields.items() + if key in fields + } + try: tmp_min = data.coords[self.y_field].values[0] except IndexError: @@ -294,7 +299,7 @@ def gen_covjson(self, metadata, data, fields): 'ranges': {} } - for key, value in self.fields.items(): + for key, value in selected_fields.items(): parameter = { 'type': 'Parameter', 'description': value['title'], @@ -315,7 +320,7 @@ def gen_covjson(self, metadata, data, fields): data = _convert_float32_to_float64(data) try: - for key, value in self.fields.items(): + for key, value in selected_fields.items(): cj['ranges'][key] = { 'type': 'NdArray', 'dataType': value['type'],