Hi,

Try 

gdal_translate
"WMS:https://maps-public.geo.nyu.edu:443/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=sdr%3Anyu_2451_43745&SRS=EPSG:4326&BBOX=-119.265762329102,35.2621765136719,-118.825294494629,35.4424705505371&format=image/png&transparent=TRUE";
service.xml -of WMS

Notice the the format must be something that supports transparency so
image/jpeg does not work.

-Jukka Rahkonen-



Carl Godkin-2 wrote
> Hi,
> 
> I'm generating WMS service description files as described here:
> https://gdal.org/drivers/raster/wms.html#generation-of-wms-service-description-xml-file
> 
> This works well, but I wonder if there's a way to request the image from
> the WMS server to be transparent.
> 
> If I use gdal_translate to create the WMS service description file like
> this:
> 
> gdal_translate "WMS:
> https://maps-public.geo.nyu.edu:443/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=sdr%3Anyu_2451_43745&SRS=EPSG:4326&BBOX=-119.265762329102,35.2621765136719,-118.825294494629,35.4424705505371";
> service.xml -of WMS
> 
> then I get this:
> <GDAL_WMS>
>   
> <Service name="WMS">
>     
> <Version>
> 1.1.1
> </Version>
>     
> <ServerUrl>
> https://maps-public.geo.nyu.edu:443/geoserver/wms?SERVICE=WMS
> </ServerUrl>
>     
> <Layers>
> sdr%3Anyu_2451_43745
> </Layers>
>     
> <SRS>
> EPSG:4326
> </SRS>
>     
> <ImageFormat>
> image/jpeg
> </ImageFormat>
>     
> <Transparent>
> FALSE
> </Transparent>
>     
> <BBoxOrder>
> xyXY
> </BBoxOrder>
>   
> </Service>
>   
> <DataWindow>
>     
> <UpperLeftX>
> -119.265762329102
> </UpperLeftX>
>     
> <UpperLeftY>
> 35.4424705505371
> </UpperLeftY>
>     
> <LowerRightX>
> -118.825294494629
> </LowerRightX>
>     
> <LowerRightY>
> 35.2621765136719
> </LowerRightY>
>     
> <SizeX>
> 1073741824
> </SizeX>
>     
> <SizeY>
> 439508252
> </SizeY>
>   
> </DataWindow>
>   
> <BandsCount>
> 3
> </BandsCount>
>   
> <BlockSizeX>
> 1024
> </BlockSizeX>
>   
> <BlockSizeY>
> 1024
> </BlockSizeY>
>   
> <OverviewCount>
> 20
> </OverviewCount>
> </GDAL_WMS>
> I have discovered that if I slightly edit three lines the service
> description like this:
> 
>     
> <ImageFormat>
> image/geotiff
> </ImageFormat>
>     
> <Transparent>
> TRUE
> </Transparent>
>  
> <BandsCount>
> 4
> </BandsCount>
> then my output image is transparent if I compare these two output files:
> 
> gdal_translate -outsize 512 512 -projwin -119.1 35.4 -119 35.3 service.xml
> bakersfield.tif
> gdal_translate -outsize 512 512 -projwin -119.1 35.4 -119 35.3
> service_trans.xml bakersfield_trans.tif
> 
> Are there some options I can use in the first gdal_translate command above
> to generate the WMS description file so that
> it retrieves transparent images if the server supports transparency?
> 
> (I am actually creating the service description file in C++ code using
> CreateCopy, but I believe it's easy to prototype with the CLI.)
> 
> Thanks very much,
> 
> carl
> 
> _______________________________________________
> gdal-dev mailing list

> gdal-dev@.osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to