[gdal-dev] Any more GDAL WMS examples?
Even Rouault
even.rouault at mines-paris.org
Thu Jan 31 06:56:07 PST 2013
Selon Carl Godkin <cgodkin at gmail.com>:
> Hi again,
>
> I am still trying to come up to speed on WMS using GDAL 1.9.2 and am
> interested in some examples beyond what are
> posted at the bottom of http://www.gdal.org/frmt_wms.html .
>
> I can run the various gdal_translate examples and some of them even work.
> (All of them need to be adjusted since the XML file name printed in the
> examples actually has "frmt_wms_" prepended, by the way.)
>
> However, I can't get anything BUT those few examples to work. For example,
> the metacarta example says this:
>
> gdal_translate -of PNG -outsize 500 250 metacarta_wmsc.xml
> metacarta_wmsc.png
>
> However, I would like to specify a smaller area than the entire world. The
> provided XML file specifies the whole world:
>
> <GDAL_WMS>
> <Service name="WMS">
> <Version>1</Version>
> <ServerUrl>http://labs.metacarta.com/wms-c/Basic.py?</ServerUrl>
> <Layers>basic</Layers>
> </Service>
> <DataWindow>
> <UpperLeftX>-180.0</UpperLeftX>
> <UpperLeftY>90.0</UpperLeftY>
> <LowerRightX>180.0</LowerRightX>
> <LowerRightY>-90.0</LowerRightY>
> <TileLevel>19</TileLevel>
> <TileCountX>2</TileCountX>
> <TileCountY>1</TileCountY>
> </DataWindow>
> <Projection>EPSG:4326</Projection>
> <BlockSizeX>256</BlockSizeX>
> <BlockSizeY>256</BlockSizeY>
> <BandsCount>3</BandsCount>
> </GDAL_WMS>
>
> Merely changing the UpperLeft/LowerRight values in the DataWindow section
> does not work, and I think it's because the server only serves data at
> specific multiples of 180/256 = 0.703125 step sizes (or something like
> that).
>
> For example, I tried to specify the window 24 to 25 degrees E and 60 to 61
> degrees N which makes a request to the server like this:
>
>
http://labs.metacarta.com/wms-c/Basic.py?service=WMS&request=GetMap&version=1&layers=basic&styles=&srs=EPSG:4326&format=image/jpeg&width=256&height=256&bbox=24,60,25,61
>
> If I paste that URL into my browser, I get this reply:
>
> An error occurred: can't find resolution index for 0.003906. Available
> resolutions are:
> [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125,
> 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125,
> 0.001373291015625, 0.0006866455078125, 0.00034332275390625,
> 0.000171661376953125, 8.58306884765625e-05, 4.291534423828125e-05,
> 2.1457672119140625e-05, 1.0728836059570312e-05,
> 5.3644180297851562e-06, 2.6822090148925781e-06,
> 1.3411045074462891e-06]
>
>
>
> I have a feeling that I'm making this a lot harder than it should be.
> Is there some bit of conditioning code somewhere that I'm overlooking?
>
> Can someone fashion an XML GDAL_WMS request that will retrieve a 1000
> x 1000 image from the lat/lon range above?
Unless you know what you are doing, don't hack the GDAL_WMS XML file for that.
The DataWindow is supposed to match the global extent of the layer on the
server, and defines how the tiles are numbered (or which requests are valid in
the case of WMS-C)
Just add the "standard" gdal_translate flags if you want to extract a subwindow
:
gdal_translate -of PNG -outsize 1000 1000 metacarta_wmsc.xml metacarta_wmsc.png
-projwin 24 61 25 60
(untested being behind corporate firewall right now)
More information about the gdal-dev
mailing list