[FWTools] Converting a black border to transparent in geotifs
Kevin Flanders
kevin at peoplegis.com
Mon Feb 12 09:04:24 EST 2007
Frank,
Does this "no data" work with ecw files in MapServer? If so, how would the
mapfile look? I cannot find any details on the website. I have ecw's with
white space that I wish to make transparent.
Kevin
-----Original Message-----
From: fwtools-bounces at lists.maptools.org
[mailto:fwtools-bounces at lists.maptools.org]On Behalf Of Frank Warmerdam
Sent: Sunday, February 11, 2007 3:00 PM
To: Simon Hook
Cc: fwtools at lists.maptools.org
Subject: Re: [FWTools] Converting a black border to transparent in
geotifs
Simon Hook wrote:
> Hi,
>
> I apologize if I sent a similar post last night but for some reason I
> did not get a copy thro' the list.
>
> I have some geotif images with a black border. I want to make the border
> transparent. Is there a way to do this with FWTools?
Simon,
In part this depends on what software you want it to be transparent in.
In some software packages (like MapServer or OpenEV) you can pick a
"nodata value" such as 0 to be treated as transparent. In some cases
the packages can also recognise nodata values as a kind of metadata from
the file. The gdal_translate -a_nodata switch can be used to assign this
nodata value to an output file though it is only preserved in some formats.
eg.
gdal_translate -a_nodata 0 in.tif out.tif
Another approach to transparency is to add an alpha channel with
explicit transparency. I think you could essentially assign all "zero"
pixels in an input greyscale image to have an alpha of zero in the output
using something like:
gdalwarp -srcnodata 0 -dstalpha in.tif out.
This whole area though is rife with challenges because:
o many software packages don't automatically support nodata values.
o some software packages don't recognise alpha bands for transparency
o some file formats don't support saving nodata values.
o some formats don't support alpha bands.
o GDAL's "nodata" data model treats nodata values as independent for
each band.
o all black pixels will get treated as transparent, not just border
values.
There are still a variety of issues I haven't addressed, but I think I'll
let you clarify what you want to do before I write more.
Best regards,
--
---------------------------------------+------------------------------------
--
I set the clouds in motion - turn up | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
_______________________________________________
FWTools mailing list
FWTools at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/fwtools
http://fwtools.maptools.org/
More information about the FWTools
mailing list