'Getting -inf values in rasterio and python

I'm using the rasterio module in Python to calculate various raster volumes.

import rasterio

filename = 'C:/test.tif'

with rasterio.open(filename) as src:
    array = src.read()
    meta = src.meta
    area = meta['transform'][0] ** 2 # Pixel size in X
volumes = array * area
total_volume = volumes.sum()

print(total_volume) 

The 1st test tiff I ran was the original tiff and it worked perfectly. The 2nd test tiff I ran was a snippet of the original which then threw up an error

C:\Python10\lib\site-packages\numpy\core\_methods.py:48: RuntimeWarning: overflow encountered in reduce
  return umr_sum(a, axis, dtype, out, keepdims, initial, where)
-inf


Solution 1:[1]

You can use gsutil command line tool

For example

gsutil cp gs://cloud-ml-data/img/openimage/csv/salads_ml_use.csv /tmp/

It may ask you to login first - just follow the commands that shows on screen.

For more details see https://cloud.google.com/storage/docs/downloading-objects#gsutil

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Karim Nosseir