# vtkGDALRasterReader may not load some TIF files correctly

**URL:** https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471
**Category:** Support
**Created:** [June 23, 2026, 1:55pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471 "2026-06-23T13:55:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tholland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tholland](https://discourse.vtk.org/u/tholland)
#### Post date: [June 23, 2026, 1:55pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471/1 "2026-06-23T13:55:05Z")

</div>

For some TIF files, the GDAL raster reader (vtkGDALRasterReader class) does not fully initialize its internal GDALData object. Specifically, the `GetSpacialRef` method of the object returns a `nullptr` with certain TIF files when I don’t think it should. In `vtkGDALRasterReader.cxx`, line 643-647 the following code throws an exception:

```cpp
const char* gcpProj = this->GDALData->GetSpatialRef()->GetName();

```

The call to `GetSpatialRef()` here returns a `nullptr` on some files. I have hacked in a null guard on a local fork that allows the file to continue reading and stops the library from crashing my application, but that can’t be the correct solution here. Surely the correct solution would be ensuring that the `GDALData` object always initializes the underlying object that `GetSpatialRef()` should be a pointer of.

Has anyone else encountered this? What is the best way forward to fix it? Should I create a pull request on the GitLab board?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 2:40pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471/2 "2026-06-23T14:40:57Z")

</div>

> [@tholland](#):
>
> For some TIF files,

Please share an example data

---

<div class="post-metadata">

### Author: ![tholland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tholland](https://discourse.vtk.org/u/tholland)
#### Post date: [June 23, 2026, 3:58pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471/3 "2026-06-23T15:58:51Z")

</div>

Here are three files that all cause this problem:

[Tif\_files.zip](https://discourse.vtk.org/uploads/short-url/vvQr9HBrhpzpBv3CqsV3kTZGas8.zip) (1.3 MB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 24, 2026, 3:04pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471/4 "2026-06-24T15:04:20Z")

</div>

I confirm the issue, the GDAL raster reader crash when opening this file, and the vtkTIFReader is struggling too.

Please open an issue: [https://gitlab.kitware.com/vtk/vtk/-/work\_items](https://gitlab.kitware.com/vtk/vtk/-/work_items)

Interestingly, the vtkPDALReader is able to open the files without issues:

 ![elevationrastertif1](https://discourse.vtk.org/uploads/default/original/2X/c/c65025d2ff3557eeffa53cd4c5c184e62df8006c.jpeg)

---

<div class="post-metadata">

### Author: ![tholland](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tholland](https://discourse.vtk.org/u/tholland)
#### Post date: [June 25, 2026, 12:26pm UTC](https://discourse.vtk.org/t/vtkgdalrasterreader-may-not-load-some-tif-files-correctly/16471/5 "2026-06-25T12:26:49Z")

</div>

Link to work issue: [https://gitlab.kitware.com/vtk/vtk/-/work\_items/20095](https://gitlab.kitware.com/vtk/vtk/-/work_items/20095)
