Skip to content

Commit e8aef58

Browse files
authored
Fix NaN values for JSON output (#2068)
1 parent 11a7f46 commit e8aef58

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pygeoapi/provider/rasterio_.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import logging
3131

32+
import numpy as np
3233
from pyproj import CRS, Transformer
3334
import rasterio
3435
from rasterio.io import MemoryFile
@@ -334,7 +335,10 @@ def gen_covjson(self, metadata, data):
334335
'shape': [metadata['height'], metadata['width']],
335336
}
336337
# TODO: deal with multi-band value output
337-
cj['ranges'][key]['values'] = data.flatten().tolist()
338+
cj['ranges'][key]['values'] = [None if isinstance(v, float)
339+
and np.isnan(v)
340+
else v for v in
341+
data.flatten().tolist()]
338342
except IndexError as err:
339343
LOGGER.warning(err)
340344
raise ProviderQueryError('Invalid query parameter')

0 commit comments

Comments
 (0)