0

Is there a way to store the output of a url that returns a geotiff (or tiff file) directly into a numpy array or rasterio variable using the python requests library (or any other python library)? I can use python requests for a json like this:

requests.get(URL).json()
user308827
  • 21,227
  • 87
  • 254
  • 417

1 Answers1

3
requests.get(URL).content

gives you the binary data from your file which you may be able to convert using the numpy.frombuffer function. But if I remember correctly, the geotiff format has some header information which you would have to offset for.

Alternatively, you could save the file to disc

open('myfile.tiff','wb').write(requests.get(URL).content)

and then read it using something like the scipy.ndimage.imread function.

Ben K.
  • 1,160
  • 6
  • 20