In an earlier post I asked how to retrieve this tag from TIFF using python and libtiff. Eventually I found the answer and I reported on the solution last week. I also realised that in order to write a proper GeoTIFF, more tags are needed than only GDAL_NODATA, viz. ModelPixelScaleTag, ModelTiepointTag, ModelTransformationTag, GeoKeyDirectoryTag, GeoDoubleParamsTag, GeoAsciiParamsTag and GDAL_METADATA. Maybe even more are needed? The GeoTIFF format specification is found here - rather extensive ...

Now I want to also know how to write private tags. It goes wrong when I reach line 934 of module libtiff_ctypes: r = libtiff.TIFFSetField(self, tag, data)

The GDAL_NODATA tag is part of the dictionary tifftags - see my earlier post. The error message that is reported is: WindowsError: exception: access violation reading 0xFFFFD8F1. What am I doing wrong?

1 Answer 1


With the help of a colleague, I have found the problem. This was my code:

tif.SetField("GDAL_NODATA", int(nodatavalue))

The definition of GDAL_NODATA I used was however like this:

TIFFFieldInfo(42113, -1, -1, TIFFDataType.TIFF_ASCII, FIELD_CUSTOM, True, False, "GDAL_NODATA")

The error is no more coming since we changed the first statement to this:

tif.SetField("GDAL_NODATA", str(nodatavalue))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.