GeoTIFF issue with opening in PIL
<p>Everytime I open an GeoTIFF image of a orthophoto in python (tried PIL, matplotlib, scipy, openCV) the image screws up. Some corners are beeing cropped , however the image remains its original shape. If I manually convert the tif to for instance a png in Photoshop and load it, it does work correctly. So it seems like PIL has some trouble handling tif files with objects that not fill the entire canvas. Does anyone have a solution for this problem?</p>

<p><em>Part of original Image:</em></p>

<p><img src="https://i.stack.imgur.com/uSjKlm.jpg" alt="Part of original Image"></p>

<p><em>After opening:</em></p>

<p><img src="https://i.stack.imgur.com/wUVk9m.jpg" alt="After opening"></p>

<p>It would've been really nice if you put the link of the figure that you are using (if it's free). I downloaded a sample geotiff image from <a href="http://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_2048.tif" rel="nofollow">here</a>, and I used <a href="https://pypi.python.org/pypi/GDAL/" rel="nofollow">gdal</a> to open it.</p>

<p>The shape of the <code>geotiff.ReadAsArray()</code> is <code>(3, 1024, 2048)</code> so I convert it to <code>(1024, 2048, 3)</code> (RGB) and open it with <code>imshow</code>: </p>

<p>import gdal
gdal.UseExceptions()
import matplotlib.pyplot as plt
import numpy as np</p>

<pre><code>geotiff = gdal.Open('/home/vafanda/Downloads/test.tif')
geotiff_arr= geotiff.ReadAsArray()
print np.shape(geotiff_arr)
geotiff_shifted = np.rollaxis(geotiff_arr,0,3)
print "Dimension converted to: "
print np.shape(geotiff_shifted)
plt.imshow(geotiff_shifted)
plt.show()
</code></pre>

<p>result: </p>

<p><a href="https://i.stack.imgur.com/JApVV.png" rel="nofollow"><img src="https://i.stack.imgur.com/JApVV.png" alt="enter image description here"></a></p>

python image scipy tiff geotiff