I am trying to use GDAL (2.0.0) Python API in Blender, but I am having some difficulties. I am trying to save geotiffs for :
- a 2D numpy array storing 32bits floats
- a 3 channels rgb numpy array of bytes [0-255].
When I do so in Python, I get two tiffs (a grayscale one that I can open in ImageJ, an RGB one I can open with anything) correctly geo-reference
The problem is that they have black strips in them, and it seems they are not at the same place everytime. In the console, I have several errors of the type:
ERROR 1: TIFFFillStrip:/home/.../test.tif: Invalid strip byte count 0, strip 269 ...
The thing is that if I am using the code below to save the grayscale array, I get a correct image (not georeferenced), so I know the data array is correct
arr_2D_uint8 = arr_2D.astype(gdalnumeric.uint8) gdalnumeric.SaveArray(arr_2D_uint8, filepath, format="GTiff")
Here is the code I use for the grayscale, which is similar for the rgb image:
srs = osr.SpatialReference() srs.ImportFromEPSG(epsg_code) driver = gdal.GetDriverByName('GTiff') ds = driver.Create(filepath, Nx, Ny, 1, gdal.GDT_Float32) ds.GetRasterBand(1).WriteArray(arr_2D.astype(gdalnumeric.float32)) ds.SetGeoTransform( (NW_x, lx, rx, NW_y, ry, -ly) ) # define GeoTransform tuple : top left x, w-e pixel resolution, rotation, top left y, rotation, n-s pixel resolution ds.SetProjection(srs.ExportToWkt()) ds = None
And here is an example image :
EDIT : Is anyone having the same issue ? I am now having the exact same problem but this time, trying to load a Geotiff. I am thinking this may come from a size limitation problem, since the geotiff I am trying to load is 3600 by 3000 pixels wide.
Do you think this may be causing the issue ? Else, does anyone have an explanation ? Do not hesitate if you need further descriptions.