# How can I read a GDAL dataset from an io stream?

**URL:** <https://discourse.julialang.org/t/how-can-i-read-a-gdal-dataset-from-an-io-stream/109679>\
**Category:** Geo\
**Created:** [February 3, 2024, 5:57pm UTC](https://discourse.julialang.org/t/how-can-i-read-a-gdal-dataset-from-an-io-stream/109679 "2024-02-03T17:57:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxfreu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxfreu/32/17468_2.png) [@maxfreu](https://discourse.julialang.org/u/maxfreu)\
**Post date:** [February 3, 2024, 5:57pm UTC](https://discourse.julialang.org/t/how-can-i-read-a-gdal-dataset-from-an-io-stream/109679/1 "2024-02-03T17:57:28Z")

</div>

Hi! I’m wondering how I can read a gdal dataset that comes in the form of some io stream. Imagine you iterate over a tar file of tifs via TarIterator. For each tif there is an io stream containing the raw dataset data as on the disk. I don’t want to use the /vsitar/ interface, because that has to scan the tar up to the desired file. Does anyone have an idea?

---

<div class="post-metadata">

**Author:** ![evetion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evetion/32/22679_2.png) [@evetion](https://discourse.julialang.org/u/evetion)\
**Post date:** [February 4, 2024, 8:18am UTC](https://discourse.julialang.org/t/how-can-i-read-a-gdal-dataset-from-an-io-stream/109679/2 "2024-02-04T08:18:06Z")

</div>

I believe it should be possible (consuming the stream though, as the length need to be known for GDAL), but it’s not a standard feature in ArchGDAL. In fact, you have to dive to GDAL, calling something like `vsifilefrommembuffer`, registring it as `"/vsimem/something"`, and then normally opening with `read("vsimem/something")`.

Feel free to make a PR exposing this functionality in ArchGDAL 🙂

---

<div class="post-metadata">

**Author:** ![maxfreu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxfreu/32/17468_2.png) [@maxfreu](https://discourse.julialang.org/u/maxfreu)\
**Post date:** [February 4, 2024, 12:14pm UTC](https://discourse.julialang.org/t/how-can-i-read-a-gdal-dataset-from-an-io-stream/109679/3 "2024-02-04T12:14:37Z")

</div>

Thank you! This does the trick, indeed:

```julia
GDAL.vsifilefrommembuffer("/vsimem/test", data, length(data), false)

```

Where data is of type Vector{UInt8} and the /vsimem/ part of the path is important.
