[Geoserver-users] Rasters with transparency

Hi all.

I have a simple problem, but so far have been unable to find a simple solution…

I have some byte-scaled geotiff images that I would like to render with transparency, specifically setting all 0 pixels to fully transparent. I can think of a couple potential solutions, but neither of them seem to work. I’ve tried:

  • Defining a no-data value within the geotiff. (GS would need to be able to interpret this value and render those values as transparent, but that doesn’t seem to be implemented.)

  • Using an SLD with a RasterSymbolizer.

This last solution would probably be ideal because it would give the client the most flexibility in defining how the data should be displayed, but I can’t seem to get this to work. I’ve tried with float-32, int-16, and byte tiff images, all with no luck.

Could someone please A. recommend the best way to solve my immediate problem, and B. give me an update on the current status of SLD RasterSymbolizer support?

Thanks!

Sam

Ciao Samuel,
a few questions may help me to provide some guidance:
- which version of geoserver are you using? RasterSymbolizer support
has gone mainstream lately, it might just be that the version you are
using does not support it.
- can you describe the data you are using in terms of the range dynamic?
- can you attach a sample sld (well, actually some sample data would
be helpful as well).

Ciao,
Simone.

On Tue, Aug 26, 2008 at 1:38 AM, Samuel Hiatt <samhiatt@anonymised.com> wrote:

Hi all.

I have a simple problem, but so far have been unable to find a simple
solution...

I have some byte-scaled geotiff images that I would like to render with
transparency, specifically setting all 0 pixels to fully transparent. I can
think of a couple potential solutions, but neither of them seem to work.
I've tried:

- Defining a no-data value within the geotiff. (GS would need to be able to
interpret this value and render those values as transparent, but that
doesn't seem to be implemented.)

- Using an SLD with a RasterSymbolizer.

This last solution would probably be ideal because it would give the client
the most flexibility in defining how the data should be displayed, but I
can't seem to get this to work. I've tried with float-32, int-16, and byte
tiff images, all with no luck.

Could someone please A. recommend the best way to solve my immediate
problem, and B. give me an update on the current status of SLD
RasterSymbolizer support?

Thanks!

Sam

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

Ciao Simone.

Grazie per rispondere…

a few questions may help me to provide some guidance:

  • which version of geoserver are you using? RasterSymbolizer support
    has gone mainstream lately, it might just be that the version you are
    using does not support it.

I am running GS 1.6.3

  • can you describe the data you are using in terms of the range dynamic?

I am working with byte data within the range 0 to 255.

Actually, the original data is floating point data, but I had to create byte-scaled versions because I am aware that geotools doesn’t yet support Categories for 32-bit data. Is this limitation true with geoserver? or should I expect to be able to style floating-point data with an SLD already, as currently implemented?

  • can you attach a sample sld (well, actually some sample data would
    be helpful as well).

I was trying to use the “raster” sld that comes packaged with the geoserver .war, just modifying the values to fit my data (but staying within 0 to 255 range). I noticed that none of the example datasets actually use this SLD… it looks like the sf dem, for example, is originally a 3-band RGB tiff.

Thanks for your help.

Sam

Ciao Samuel,
please read below...

On Tue, Aug 26, 2008 at 2:08 AM, Samuel Hiatt <samhiatt@anonymised.com> wrote:

Ciao Simone.

Grazie per rispondere...

Di niente :slight_smile:

a few questions may help me to provide some guidance:
- which version of geoserver are you using? RasterSymbolizer support
has gone mainstream lately, it might just be that the version you are
using does not support it.

I am running GS 1.6.3

Unfortunately this version does not have a rastersymbolizer implemented.
I wanted to port the RasterSymbolizer work to the 1.6.x branch but, if
my memory serves me right (it is quite late here) I never manage to do
it.
If you want to play with the raster symbolizer (feedback welcome :slight_smile: )
you should try the 1.7.0-rc1 release, you can find it here
http://geoserver.org/display/GEOS/GeoServer+1.7.0-RC1.
Note that shortly RC2 should be out as well.

- can you describe the data you are using in terms of the range dynamic?

I am working with byte data within the range 0 to 255.

Actually, the original data is floating point data, but I had to create
byte-scaled versions because I am aware that geotools doesn't yet support
Categories for 32-bit data. Is this limitation true with geoserver? or
should I expect to be able to style floating-point data with an SLD already,
as currently implemented?

The raster symbolizer I implemented for GeoTools should be able to
handle any kind of data with no problems (crossing fingers :slight_smile: ).
Of course doing contrast enhancement and/or gamma correction on
floating point data is rather different than doing the same on byte
data hence, feedback on that is greatly appreciated.
As of the RasterSymbolizer element itself, it should work fine on
every type of data. I have tested it on unsigned short, short, float,
double and byte.

- can you attach a sample sld (well, actually some sample data would
be helpful as well).

I was trying to use the "raster" sld that comes packaged with the geoserver
.war, just modifying the values to fit my data (but staying within 0 to 255
range). I noticed that none of the example datasets actually use this
SLD... it looks like the sf dem, for example, is originally a 3-band RGB
tiff.

As I said above, older version of GeoServer simply ignored the SLD
raster symbolizer, we used (internally) vendor parameters to change
the styling of the coverages, but being an ugly hack we never commited
it to the public version. Since 1.7.0 however RasterSymbolizer should
start working.

Ciao,
Simone.

Thanks for your help.

Sam

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

Ciao Simone!

I am running GS 1.6.3

Unfortunately this version does not have a rastersymbolizer implemented.
I wanted to port the RasterSymbolizer work to the 1.6.x branch but, if
my memory serves me right (it is quite late here) I never manage to do
it.
If you want to play with the raster symbolizer (feedback welcome :slight_smile: )
you should try the 1.7.0-rc1 release, you can find it here
http://geoserver.org/display/GEOS/GeoServer+1.7.0-RC1.
Note that shortly RC2 should be out as well.

That explains everything! I’ll give 1.7 a shot.

As of the RasterSymbolizer element itself, it should work fine on
every type of data. I have tested it on unsigned short, short, float,
double and byte.

Awesome! That is really good news!

Thanks again… this should solve my problem.

Buona sera!

Sam

SamHiatt wrote:

I have some byte-scaled geotiff images that I would like to render with
transparency, specifically setting all 0 pixels to fully transparent.

If you are handy with C and GDAL, see the attached snippet of example code
that adds an alpha layer to a one-band 8-bit GeoTIFF. Although it is not
incredibly convenient to have to pre-process your GeoTIFFs, GeoServer 1.6.x
supports an alpha layer added in this fashion.

Cheers,
Ryan

http://www.nabble.com/file/p19154134/makeblackalpha.c makeblackalpha.c

--
View this message in context: http://www.nabble.com/Rasters-with-transparency-tp19153574p19154134.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Buongiorno Simone!

Thanks again for your help yesterday with the RasterSymbolizer tips. I’m pretty excited that I have dynamic styling of my floating-point rasters working. :slight_smile:

One issue:

At scales 1:7M or greater it seems when the image is down-sampled all pixels near zero (my values range from -0.1 to 0.1) end up set to zero, resulting in a flat blue image in my case. However, at scales of 1:4M or smaller (more zoomed-in) everything works fine and I get a nice pretty image, as expected.

I’m using default (nearest) interpolation…

Any ideas what is going on?

Grazie per tuto!

Sam

On Mon, Aug 25, 2008 at 5:44 PM, Samuel Hiatt <samhiatt@anonymised.com> wrote:

Ciao Simone!

I am running GS 1.6.3

Unfortunately this version does not have a rastersymbolizer implemented.
I wanted to port the RasterSymbolizer work to the 1.6.x branch but, if
my memory serves me right (it is quite late here) I never manage to do
it.
If you want to play with the raster symbolizer (feedback welcome :slight_smile: )
you should try the 1.7.0-rc1 release, you can find it here
http://geoserver.org/display/GEOS/GeoServer+1.7.0-RC1.
Note that shortly RC2 should be out as well.

That explains everything! I’ll give 1.7 a shot.

As of the RasterSymbolizer element itself, it should work fine on
every type of data. I have tested it on unsigned short, short, float,
double and byte.

Awesome! That is really good news!

Thanks again… this should solve my problem.

Buona sera!

Sam

Hi Simone!

Thanks. Adding internal overviews to the tiffs using gdaladdo to seems to have solved the problem, (and also speeds things up quite a bit).

Ciao!
Sam

On Wed, Aug 27, 2008 at 1:09 PM, Simone Giannecchini <simboss1@anonymised.com> wrote:

Quick update,
believe it or not it seems that the imageio tiff reader fails to
decode float and double tiff files when subsampling is used.
Can you try to use overviews levels at like 2 4 8 16 32 64 128 so that
decimation on reading does not get used and tell what happens?

Back to investigation…
Simone.

Ciao Samuel,
I found the cause of the problems in the end. The imageio
TiffImageReader converts everything to int when dcimation on reading
is applied through the usage of ImageReadParams. I have fixed that and
createed a new release of Imageio (and JAI as well, since I had it on
my hd already :-)).
I will submit a bug report with the patch attached, but if anyone
wants to get the fixes I can provude them.
Regards,
Simone.

PS
I have cced the geotools users list just in case someone bumps into
the same problem

On Thu, Aug 28, 2008 at 12:17 AM, Samuel Hiatt <samhiatt@anonymised.com> wrote:

Hi Simone!

Thanks. Adding internal overviews to the tiffs using gdaladdo to seems to
have solved the problem, (and also speeds things up quite a bit).

Ciao!
Sam

On Wed, Aug 27, 2008 at 1:09 PM, Simone Giannecchini <simboss1@anonymised.com>
wrote:

Quick update,
believe it or not it seems that the imageio tiff reader fails to
decode float and double tiff files when subsampling is used.
Can you try to use overviews levels at like 2 4 8 16 32 64 128 so that
decimation on reading does not get used and tell what happens?

Back to investigation...
Simone.

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------