Skip to content

Commit 179c90f

Browse files
authored
Fixes a memoryfile issue with rasterio. When using f=json, it doesn't need to use the MemoryFile. (geopython#1824)
1 parent e736fa3 commit 179c90f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pygeoapi/provider/rasterio_.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,15 @@ def query(self, properties=[], subsets={}, bbox=None, bbox_crs=4326,
240240
out_meta['units'] = _data.units
241241

242242
LOGGER.debug('Serializing data in memory')
243-
with MemoryFile() as memfile:
244-
with memfile.open(**out_meta) as dest:
245-
dest.write(out_image)
246-
247-
if format_ == 'json':
248-
LOGGER.debug('Creating output in CoverageJSON')
249-
out_meta['bands'] = args['indexes']
250-
return self.gen_covjson(out_meta, out_image)
251-
252-
else: # return data in native format
243+
if format_ == 'json':
244+
LOGGER.debug('Creating output in CoverageJSON')
245+
out_meta['bands'] = args['indexes']
246+
return self.gen_covjson(out_meta, out_image)
247+
248+
else: # return data in native format
249+
with MemoryFile() as memfile:
250+
with memfile.open(**out_meta) as dest:
251+
dest.write(out_image)
253252
LOGGER.debug('Returning data in native format')
254253
return memfile.read()
255254

0 commit comments

Comments
 (0)