[gdal-dev] Fwd: Transparency in GDAL WMS
Joel Odom
joelodom at gmail.com
Tue Jun 23 13:00:51 EDT 2009
Update. Now I think I understand the issue. Here is the resolution:
<BandsCount>4</BandsCount> missing from the config file, not a bug.
Thanks!
---------- Forwarded message ----------
From: Joel Odom <joelodom at gmail.com>
Date: Tue, Jun 23, 2009 at 12:21 PM
Subject: Fwd: Transparency in GDAL WMS
To: gdal-dev at lists.osgeo.org
For posterity, here is some information about a GDAL WMS driver issue. I
opened ticket 3042 to address this. I hope no one minds if I paste the
transcript of the conversation below. I often search this list archive for
information about GDAL issues and figure this may be useful to have in the
archive. Thanks.
Transcript of conversation:
Joel Odom <joelodom at gmail.com>
Transparency in GDAL WMS
10 messages
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 9:36 AM
To: Frank Warmerdam <warmerdam at pobox.com>
Hi, Frank. I'm hitting a WMS link that returns a PNG with transparency, but
the data set raster count says that it has only three bands. We're on GDAL
1.5.2. Another researcher here says that newer versions of GDAL support WMS
transparency, but I can't find any mention of it in this group or on in
Trac. Is it correct that this feature was put in a later release and do you
know which release? Thanks.
(By the way, there is an early, fairly buggy, alpha of FalconView 4.3
available for free download now from http://www.falconview.org/. We've also
posted the FalconView source code there.)
--
http://giscoder.blogspot.com/
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 9:51 AM
To: Frank Warmerdam <warmerdam at pobox.com>
I think this may be what the other researcher here was looking at when he
said a newer version of GDAL:
http://trac.osgeo.org/mapserver/ticket/83 This ticket refers to
something about 8 years ago, though, so it's probably
not the issue.
Here is the WMS request that is returning a transparent PNG. Any idea why
I'm getting this back as a three band raster and not seeing an alpha band?
Thanks so much.
http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n1p.cgi?TRANSPARENT=TRUE&request=GetMap&version=1.1.0&layers=nexrad-n1p&styles=&srs=EPSG:4326&format=image/png&width=948&height=603&bbox=-106.24059800,39.92912300,-97.79391800,45.30185300
[Quoted text hidden]
--
http://giscoder.blogspot.com/
Frank Warmerdam <warmerdam at pobox.com> Tue, Jun 23, 2009 at 10:08 AM
To: Joel Odom <joelodom at gmail.com>
Joel Odom wrote:
I think this may be what the other researcher here was looking at when he
said a newer version of GDAL:
http://trac.osgeo.org/mapserver/ticket/83 This ticket refers to
something about 8 years ago, though, so it's probably
not the issue.
Here is the WMS request that is returning a transparent PNG. Any idea why
I'm getting this back as a three band raster and not seeing an alpha band?
Thanks so much.
http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n1p.cgi?TRANSPARENT=TRUE&request=GetMap&version=1.1.0&layers=nexrad-n1p&styles=&srs=EPSG:4326&format=image/png&width=948&height=603&bbox=-106.24059800,39.92912300,-97.79391800,45.30185300<
http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n1p.cgi?TRANSPARENT=TRUE&request=GetMap&version=1.1.0&layers=nexrad-n1p&styles=&srs=EPSG:4326&format=image/png&width=948&height=603&bbox=-106.24059800,39.92912300,-97.79391800,45.30185300
>
Joel,
There are two ways of accomplishing transparency in PNG. One is to add an
alpha band. The other is to designate a color index as transparent in
a single band image with a color table. That is the approach used in this
image.
Driver: PNG/Portable Network Graphics
Files: /wrk/home/warmerda/n1p.cgi.png
Size is 948, 603
Coordinate System is `'
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 603.0)
Upper Right ( 948.0, 0.0)
Lower Right ( 948.0, 603.0)
Center ( 474.0, 301.5)
Band 1 Block=948x1 Type=Byte, ColorInterp=Palette
NoData Value=0
Color Table (RGB with 45 entries)
0: 255,255,255,0
1: 104,34,139,255
2: 154,50,205,255
3: 178,58,238,255
4: 191,62,255,255
5: 153,85,201,255
...
Note that alpha=0 in the color value for index zero. The "nodata" metadata
is also set to refer to color index zero. So for this image all zero pixels
should be treated as transparent.
Does that address your problem?
Hopefully I can try out FalconView soon. I skimmed the page and I'm
impressed with the project.
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 | Geospatial Programmer for Rent
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 10:57 AM
To: Frank Warmerdam <warmerdam at pobox.com>
Thanks, Frank. That gives me a lot of insight into what's going on, but it
raises a new question. When I hit the WMS using GDALOpen on an XML file
with the WMS connect data, I get something different than when I hit the URL
below with my browser, save the image, then open the saved PNG file with
GDALOpen. I see the color table when I open the PNG and see the single band
raster, but rasterBand->GetColorTable() returns null when I open the WMS
from the XML file and I see a three band raster. Why would I get back
different data from the different data sources? It's like the WMS data
source is doing some interpretation on the image that discards original
single band image and creates a new three band image with no transparency.
Thanks for checking out FalconView. We've been very popular in DoD mission
planning for about 15 years now. We're opening up to the public as an
open-source GIS product. Part of that effort involves aligning with OGC
standards like WMS, KML, etc. We're using GDAL and OGR as a big part of
that effort and really appreciate the product.
[Quoted text hidden]
--
http://giscoder.blogspot.com/
Frank Warmerdam <warmerdam at pobox.com> Tue, Jun 23, 2009 at 11:10 AM
To: Joel Odom <joelodom at gmail.com>
Joel Odom wrote:
Thanks, Frank. That gives me a lot of insight into what's going on, but it
raises a new question. When I hit the WMS using GDALOpen on an XML file
with the WMS connect data, I get something different than when I hit the URL
below with my browser, save the image, then open the saved PNG file with
GDALOpen. I see the color table when I open the PNG and see the single band
raster, but rasterBand->GetColorTable() returns null when I open the WMS
from the XML file and I see a three band raster. Why would I get back
different data from the different data sources? It's like the WMS data
source is doing some interpretation on the image that discards original
single band image and creates a new three band image with no transparency.
Joel,
Could you provide your wms xml control file for GDAL? I'd like to try
this. I was not really much involved in the development of the GDAL WMS
driver so I'm not clear on how it works internally. It appears to be
doing substantial image manipulation and it might need some further
adjustments for this case.
Thanks for checking out FalconView. We've been very popular in DoD mission
planning for about 15 years now. We're opening up to the public as an
open-source GIS product. Part of that effort involves aligning with OGC
standards like WMS, KML, etc. We're using GDAL and OGR as a big part of
that effort and really appreciate the product.
Excellent!
[Quoted text hidden]
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 11:15 AM
To: Frank Warmerdam <warmerdam at pobox.com>
Here it is. I'm constructing this as an in-memory string, saving it to an
in-memory file using the VSI stuff, then calling GDALOpen on the file.
Thanks!
<GDAL_WMS>
<Service name="WMS">
<ServerURL>
http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n1p.cgi?TRANSPARENT=TRUE
</ServerURL>
<ImageFormat>image/png</ImageFormat>
<Layers>nexrad-n1p</Layers>
</Service>
<DataWindow>
<UpperLeftX>-102.017258</UpperLeftX>
<UpperLeftY>47.974853</UpperLeftY>
<LowerRightX>-93.570578</LowerRightX>
<LowerRightY>42.602123</LowerRightY>
<SizeX>948</SizeX>
<SizeY>603</SizeY>
</DataWindow>
<Timeout>45</Timeout>
</GDAL_WMS>
[Quoted text hidden]
--
http://giscoder.blogspot.com/
Frank Warmerdam <warmerdam at pobox.com> Tue, Jun 23, 2009 at 11:52 AM
To: Joel Odom <joelodom at gmail.com>
Joel Odom wrote:
Here it is. I'm constructing this as an in-memory string, saving it to an
in-memory file using the VSI stuff, then calling GDALOpen on the file.
Thanks!
Joel,
I see what you mean. I believe the approach taken in the WMS driver is
essentially obliterating any concept of transparency in the result. It
would take some non-trivial additional development in the WMS driver to
address this issue. I'm not in a position to do it.
You might want to take up the issue with Adam Nowaki who wrote the the
driver. Possibly I'm missing something, or perhaps he would be willing
to do some work on this.
[Quoted text hidden]
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 11:55 AM
To: Frank Warmerdam <warmerdam at pobox.com>
Cc: Chris Bailey <chris.bailey at gtri.gatech.edu>
Thanks, Frank. I appreciate that. My work-around for now is to request the
URL myself then have GDAL interpret the image using whatever driver it finds
appropriate for the binary image. I've almost got that working.
Would you mind if I posted this conversation to the GDAL developers list for
posterity and opened a ticket for this issue?
Thanks again.
[Quoted text hidden]
--
http://giscoder.blogspot.com/
Frank Warmerdam <warmerdam at pobox.com> Tue, Jun 23, 2009 at 12:01 PM
To: Joel Odom <joelodom at gmail.com>
Cc: Chris Bailey <chris.bailey at gtri.gatech.edu>
Joel Odom wrote:
Thanks, Frank. I appreciate that. My work-around for now is to request the
URL myself then have GDAL interpret the image using whatever driver it finds
appropriate for the binary image. I've almost got that working.
Would you mind if I posted this conversation to the GDAL developers list for
posterity and opened a ticket for this issue?
Joel,
That would be an excellent idea.
[Quoted text hidden]
Joel Odom <joelodom at gmail.com> Tue, Jun 23, 2009 at 12:17 PM
Draft To: gdal-dev at lists.osgeo.org
For posterity, here is some information about a GDAL WMS driver issue. I
opened ticket 3042 to address this. Thanks.
[Quoted text hidden]
--
http://giscoder.blogspot.com/
--
http://giscoder.blogspot.com/
--
http://giscoder.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090623/1f6cdb48/attachment-0001.html
More information about the gdal-dev
mailing list