Skip to content

Commit

Permalink
Fixes a memoryfile issue with rasterio. When using f=json, it doesn't…
Browse files Browse the repository at this point in the history
… need to use the MemoryFile. (geopython#1824)
  • Loading branch information
Alex-NRCan authored Oct 3, 2024
1 parent e736fa3 commit 179c90f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pygeoapi/provider/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,15 @@ def query(self, properties=[], subsets={}, bbox=None, bbox_crs=4326,
out_meta['units'] = _data.units

LOGGER.debug('Serializing data in memory')
with MemoryFile() as memfile:
with memfile.open(**out_meta) as dest:
dest.write(out_image)

if format_ == 'json':
LOGGER.debug('Creating output in CoverageJSON')
out_meta['bands'] = args['indexes']
return self.gen_covjson(out_meta, out_image)

else: # return data in native format
if format_ == 'json':
LOGGER.debug('Creating output in CoverageJSON')
out_meta['bands'] = args['indexes']
return self.gen_covjson(out_meta, out_image)

else: # return data in native format
with MemoryFile() as memfile:
with memfile.open(**out_meta) as dest:
dest.write(out_image)
LOGGER.debug('Returning data in native format')
return memfile.read()

Expand Down

0 comments on commit 179c90f

Please sign in to comment.