Maybe this was a bit premature. <br><br>Unfortunately, the MEM dataset does not support the SetGCPs method, even though the documentation says it 'should' .<br>("
Memory datasets should support for most kinds of auxilary information
including metadata, coordinate systems, georeferencing, GCPs,
color interpretation, nodata, color tables and all pixel data types.")<br><br>This works with the GTiff driver, but not with MEM:<br><br>import gdal<br>import gdal_array<br>import gdalconst<br>import numpy<br><br>rows = 10
<br>cols = 10<br><br>data = numpy.ones((rows,cols), numpy.int16)<br><br>driver = gdal.GetDriverByName('MEM')<br>image = driver.Create('dummy', rows, cols, 1, gdalconst.GDT_Int16)<br>gcps = []<br>gcps.append
(gdal.GCP(1,2,3,4))<br>image.SetGCPs(gcps, '')<br><br><br>Ludwig<br><br><br><div><span class="gmail_quote">On 28/05/07, <b class="gmail_sendername">Ludwig M Brinckmann</b> <<a href="mailto:ludwigbrinckmann@gmail.com">
ludwigbrinckmann@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Many thanks, <br><br>that seems to work beautifully.
<br><br>So far I had been using tiff images as an intermediate container when creating files for which no Create() method is available, but the in memory MEM format of course is much superior, no fuss with temp files and no need to write to disk.
<br><br>Regards<br><span class="sg"><br>Ludwig</span><div><span class="e" id="q_112d2c06c1a43828_2"><br><br><br><div><span class="gmail_quote">On 28/05/07, <b class="gmail_sendername">Frank Warmerdam</b> <<a href="mailto:warmerdam@pobox.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
warmerdam@pobox.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ludwig M Brinckmann wrote:<br>> I need to create paletted PNG files with transparency.<br>><br>> I understand that I need to pass in a colour table with the alpha<br>> channel set to 0.<br>><br>> As I cannot create PNGs directly, I first create a Tiff with the
<br>> colourtable and then do a CreateCopy.<br>><br>> But when I then look at the PNG colour table, the transparency values<br>> are gone (all set to 255). This is also true for the intermediate Tiff<br>> file -- which is understandable as single band tiffs don't do
<br>> transparency. I think when creating the tiff the colourtable is adjusted<br>> so that it works for the Tiff, but then my transparencies are lost. (If<br>> someone thinks this is a bug, I will turn my code into a short example).
<br>><br>> I tried to alter the colour table after creating the tiff (or the<br>> createCopy of the PNG), but this is not supported.<br>><br>> What's the best way to do this -- maybe I just need a better
<br>> intermediate format that does transparencies and can be created (which<br>> one?)<br><br>Ludwig,<br><br>If you image isn't too large, and you are doing programatically (or<br>via scripts) you might want to use MEM format as your intermediate format.
<br>I believe it supports fully featured color tables, and no mess and fuss<br>with intermediate file cleanup.<br><br> <a href="http://www.gdal.org/frmt_mem.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.gdal.org/frmt_mem.html</a><br><br>Note, when creating MEM datasets and not needing to attach to an existing
<br>array in memory, just use any name for the dataset, such as "tempimage".<br><br>Best regards,<br>--<br>---------------------------------------+--------------------------------------<br>I set the clouds in motion - turn up | Frank Warmerdam,
<a href="mailto:warmerdam@pobox.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/%7Ewarmerdam" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://pobox.com/~warmerdam</a><br>and watch the world go round - Rush | President OSGeo,
<a href="http://osgeo.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://osgeo.org</a><br><br></blockquote></div><br>
</span></div></blockquote></div><br>