<HTML>
<style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>I reinstalled everything, and then still something went wrong. Here I have to tell you a little more on my goal: I was trying to convert a slice of opendap data into netcdf. For this I use Pydap (works well). <br>
<br>
I found out that using an 2D array populated in a loop was saved as a GTiff without a problem, but the PyDap arrays were a problem. Turned out that Pydap returns a big-endian 32bit integer ( '>i4' ). Converting this to 'normal' int32 resulted in a perfect image:<br>
<br>
instead of :<br>
<br>
a = dataset['klasse'][1:9,1:9,5].array[:]<br>
<br>
I used:<br>
<br>
a = dataset['klasse'][1:9,1:9,5].array[:].view(dtype = 'int32')<br>
a[:] = dataset['klasse'][1:9,1:9,5].array[:]<br>
<br>
Is this something to request a ticket for in GDAL to support? Not a real big deal, but it takes time to convert obviously.<br>
<br>
Tom<br>
<br>
<span style="font-weight: bold;">On Fri 28/10/11 11:10 , "Chris Yesson" Chris.Yesson@ioz.ac.uk sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">Tom,<br>
<br>
I have just run your code exactly as you sent it (except for output<br>
path), with python 2.5.2 ang gdal 1.8.1. The ouput file appears in<br>
order (gdalinfo output below). The file opens and displays normally in<br>
qgis trunk v 1.8.<br>
<br>
- Chris<br>
<br>
Gdalinfo output<br>
<br>
Driver: GTiff/GeoTIFF<br>
Files: output.tif<br>
output.tif.aux.xml<br>
Size is 10, 10<br>
Coordinate System is:<br>
LOCAL_CS["arbitrary",<br>
UNIT["metre",1,<br>
AUTHORITY["EPSG","9001"]]]<br>
Metadata:<br>
AREA_OR_POINT=Area<br>
Image Structure Metadata:<br>
INTERLEAVE=BAND<br>
Corner Coordinates:<br>
Upper Left ( 0.0, 0.0)<br>
Lower Left ( 0.0, 10.0)<br>
Upper Right ( 10.0, 0.0)<br>
Lower Right ( 10.0, 10.0)<br>
Center ( 5.0, 5.0)<br>
Band 1 Block=10x10 Type=Byte, ColorInterp=Gray<br>
Min=1.000 Max=1.000<br>
Minimum=1.000, Maximum=1.000, Mean=1.000, StdDev=0.000<br>
Metadata:<br>
STATISTICS_MINIMUM=1<br>
STATISTICS_MAXIMUM=1<br>
STATISTICS_MEAN=1<br>
STATISTICS_STDDEV=0<br>
<br>
Date: Fri, 28 Oct 2011 10:23:04 +0200<br>
From: Tom van der Putte <<a href="javascript:top.opencompose('tom@vdputte.nl','','','')">tom@vdputte.nl</a>><br>
Subject: [gdal-dev] empty Gtiff from Python<br>
To: <<a href="javascript:top.opencompose('gdal-dev@lists.osgeo.org','','','')">gdal-dev@lists.osgeo.org</a>><br>
Message-ID: <<a href="javascript:top.opencompose('4335.1319790184@vdputte.nl','','','')">4335.1319790184@vdputte.nl</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi<br>
List,<br>
I'm trying to save a numpy array to a GTiff, which should be quite<br>
straightforward, considering all the examples available on the web.<br>
However, I get an file that is not readable by Qgis, is regarded by<br>
ArcMap to have only 0 and gdalinfo displays nothing on the values.<br>
I start with a ndarray, dtype = int32, shape = ( 10,10). It has<br>
integer values between 1 and 10. The code is as follows:<br>
import numpy as np<br>
from osgeo import gdal<br>
from osgeo import osr<br>
#np array<br>
a = np.ones((10,10))<br>
#coord-system<br>
sr_str = 'LOCAL_CS["arbitrary"]'<br>
sr = osr.SpatialReference( sr_str )<br>
#driver<br>
driver = gdal.GetDriverByName("GTiff")<br>
#dataset<br>
ds = driver.Create("D:\temp\output.tif", 10, 10, 1, gdal.GDT_Byte)<br>
ds.SetProjection( sr_str )<br>
ds.SetGeoTransform((0, 1, 0,0, 0,1))<br>
#write and close<br>
ds.GetRasterBand(1).WriteArray(a)<br>
ds = None<br>
The corresponding gdalinfo is:<br>
*********<br>
Raster dataset parameters:<br>
Projection:<br>
LOCAL_CS["arbitrary",UNIT["metre",1,AUTHORITY["EPSG","9001"]]]<br>
RasterCount: 1<br>
RasterSize (10,10)<br>
Using driver GeoTIFF<br>
Metadata:<br>
0: AREA_OR_POINT=Area<br>
Image Structure Metadata:<br>
0: INTERLEAVE=BAND<br>
Corner Coordinates:<br>
Upper Left (0, 0)<br>
Lower Left (0, 10)<br>
Upper Right (10, 0)<br>
Lower Right (10, 10)<br>
Center (5, 5)<br>
Coordinate System is:<br>
LOCAL_CS["arbitrary",<br>
UNIT["metre",1,<br>
AUTHORITY["EPSG","9001"]]]<br>
Band 1 :<br>
DataType: Byte<br>
ColorInterpretation: Gray<br>
Description:<br>
Size (10,10)<br>
BlockSize (10,10)<br>
*********<br>
I have tried both version 1.6.3 (I'm trying to make a Qgis plugin,<br>
and thus restricted to 1.6.3) as well as 1.8.1. I have also tried ds =<br>
driver.Create("D:\temp\output.tif", 10, 10, 1, gdal.GDT_Int32), but<br>
that didn't make much difference.<br>
I tried to make a Surfer grid (GSBG), and this somewhat worked: it<br>
gave a nice picture, but the values were off the charts.<br>
Any clues as to what I'm missing here? Cheers,<br>
Tom van der Putte<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL:<br>
<a target="_blank" href="parse.php?redirect=http%3A%2F%2Flists.osgeo.org%2Fpipermail%2Fgdal-dev%2Fattachments%2F20111028%2Fd4d82f44%2F"><span style="color: red;">http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111028/d4d82f44/</span></a><br>
attachment-0001.html<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="javascript:top.opencompose('gdal-dev@lists.osgeo.org','','','')">gdal-dev@lists.osgeo.org</a><br>
<a target="_blank" href="parse.php?redirect=http%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgdal-dev"><span style="color: red;">http://lists.osgeo.org/mailman/listinfo/gdal-dev</span></a><br>
<br>
End of gdal-dev Digest, Vol 89, Issue 71<br>
****************************************<br>
<br>
<br>
This message has been scanned for viruses by MailControl -<br>
<a target="_blank" href="parse.php?redirect=<a href="http://www.mailcontrol.com">http://www.mailcontrol.com</a>">www.mailcontrol.com</a><br>
<br>
Click<br>
<a target="_blank" href="parse.php?redirect=https%3A%2F%2Fwww.mailcontrol.com%2Fsr%2FwQw0zmjPoHdJTZGyOCrrhg"><span style="color: red;">https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg</span></a>==<br>
oTJhgA1yNPXUJ0FMnJ7X3MJaL!eAyER2lygvJyt6ermNw== to report this email as<br>
spam.<br>
<br>
<br>
The Zoological Society of London is incorporated by Royal Charter<br>
Principal Office England. Company Number RC000749<br>
Registered address: <br>
Regent's Park, London, England NW1 4RY<br>
Registered Charity in England and Wales no. 208728 <br>
<br>
_________________________________________________________________________<br>
This e-mail has been sent in confidence to the named addressee(s).<br>
If you are not the intended recipient, you must not disclose or distribute<br>
it in any form, and you are asked to contact the sender immediately.<br>
Views or opinions expressed in this communication may not be those<br>
of The Zoological Society of London and, therefore, The Zoological<br>
Society of London does not accept legal responsibility for the contents<br>
of this message. The recipient(s) must be aware that e-mail is not a<br>
secure communication medium and that the contents of this mail may<br>
have been altered by a third party in transit.<br>
If you have any issues regarding this mail please contact:<br>
<a href="javascript:top.opencompose('administrator@zsl.org','','','')">administrator@zsl.org</a>.<br>
___________________________________________________________________________<br>
<br>
<br>
<br>
This message has been scanned for viruses by MailControl, a service from BlackSpider Technologies.<br>
<br>
</blockquote></HTML>