Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
transparent geotiff

Subject: transparent geotiff

From: Matthew

Date: 1 Jul, 2011 15:12:09

Message: 1 of 5

Is it possible to write a geotiff with transparency?

The imwrite function has support for transparent gif and png. But I want to write a geotiff file. The geotiffwrite documentation doesn't say anything about transparency, although I believe the geotiff format does support transparency.


Thanks Matt

Subject: transparent geotiff

From: Ashish

Date: 1 Jul, 2011 18:02:33

Message: 2 of 5

On Fri, 01 Jul 2011 11:12:09 -0400, Matthew <mattinjersey@yahoo.com>
wrote:

> Is it possible to write a geotiff with transparency?
>
> The imwrite function has support for transparent gif and png. But I want
> to write a geotiff file. The geotiffwrite documentation doesn't say
> anything about transparency, although I believe the geotiff format does
> support transparency.
>
>
> Thanks Matt

Matt, you could try to leverage the Tiff class
http://www.mathworks.com/help/techdoc/ref/tiffclass.html to get this done
(geotiff is a type of tiff file)
Look at 'ExtraSamples'.

Its not simple, but might be able to get it to submit to your wishes.

Subject: transparent geotiff

From: Kelly Luetkemeyer

Date: 5 Jul, 2011 19:53:11

Message: 3 of 5

Hi Matt,

You can leverage what Ashish mentioned by using the 'TiffTags' name-value pair in GEOTIFFWRITE. I thinks this might work for you:

[X, R] = geotiffread('boston.tif');
info = geotiffinfo('boston.tif');

% Alpha mask -- use your own here
X(:,:,4) = X(:,:,3);

% use TiffTags
geotiffwrite('outfile.tif', X, R, ...
   'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag, ...
   'TiffTags', struct( ...
   'ExtraSamples',Tiff.ExtraSamples.AssociatedAlpha, ...
   'Photometric',Tiff.Photometric.Separated))

figure
A = imread('outfile.tif');
h=imshow(A(:,:,1:3))
set(h,'AlphaData',A(:,:,4))

or display with Mapping Toolbox
figure
mapshow(A(:,:,1:3), R, 'DisplayType', 'image', 'AlphaData', A(:,:,4));

I'm not sure if this is exactly what you were looking for but hopefully it will help you out.

-Kellly

Subject: transparent geotiff

From: Matthew

Date: 6 Jul, 2011 20:15:27

Message: 4 of 5

Yes it is very helpful. Thanks Matt


"Kelly Luetkemeyer" wrote in message <iuvq37$nu1$1@newscl01ah.mathworks.com>...
> Hi Matt,
>
> You can leverage what Ashish mentioned by using the 'TiffTags' name-value pair in GEOTIFFWRITE. I thinks this might work for you:
>
> [X, R] = geotiffread('boston.tif');
> info = geotiffinfo('boston.tif');
>
> % Alpha mask -- use your own here
> X(:,:,4) = X(:,:,3);
>
> % use TiffTags
> geotiffwrite('outfile.tif', X, R, ...
> 'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag, ...
> 'TiffTags', struct( ...
> 'ExtraSamples',Tiff.ExtraSamples.AssociatedAlpha, ...
> 'Photometric',Tiff.Photometric.Separated))
>
> figure
> A = imread('outfile.tif');
> h=imshow(A(:,:,1:3))
> set(h,'AlphaData',A(:,:,4))
>
> or display with Mapping Toolbox
> figure
> mapshow(A(:,:,1:3), R, 'DisplayType', 'image', 'AlphaData', A(:,:,4));
>
> I'm not sure if this is exactly what you were looking for but hopefully it will help you out.
>
> -Kellly

Subject: transparent geotiff

From: Kirsty

Date: 17 Oct, 2012 09:24:09

Message: 5 of 5

Hi Guys, I was wondering if you could help me on this subject. I have tried your suggestion to try and remove a black border around roated images but it makes the border go white instead. I need the Border transparent so that i can join images together. Any ideas?

I had also considered if it would be possible to edit the corner co-ordinates in the geotifinfo and rewrite the original none-rotated image with these- but i cannot work out a way to ensure this information is included in the writing out process.
Any help would be wonderful

Thank you
"Matthew " <mattinjersey@yahoo.com> wrote in message <iv2fov$fof$1@newscl01ah.mathworks.com>...
> Yes it is very helpful. Thanks Matt
>
>
> "Kelly Luetkemeyer" wrote in message <iuvq37$nu1$1@newscl01ah.mathworks.com>...
> > Hi Matt,
> >
> > You can leverage what Ashish mentioned by using the 'TiffTags' name-value pair in GEOTIFFWRITE. I thinks this might work for you:
> >
> > [X, R] = geotiffread('boston.tif');
> > info = geotiffinfo('boston.tif');
> >
> > % Alpha mask -- use your own here
> > X(:,:,4) = X(:,:,3);
> >
> > % use TiffTags
> > geotiffwrite('outfile.tif', X, R, ...
> > 'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag, ...
> > 'TiffTags', struct( ...
> > 'ExtraSamples',Tiff.ExtraSamples.AssociatedAlpha, ...
> > 'Photometric',Tiff.Photometric.Separated))
> >
> > figure
> > A = imread('outfile.tif');
> > h=imshow(A(:,:,1:3))
> > set(h,'AlphaData',A(:,:,4))
> >
> > or display with Mapping Toolbox
> > figure
> > mapshow(A(:,:,1:3), R, 'DisplayType', 'image', 'AlphaData', A(:,:,4));
> >
> > I'm not sure if this is exactly what you were looking for but hopefully it will help you out.
> >
> > -Kellly

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us