WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 346ac36

Browse files
committed
docs: update WMS example
1 parent 0b8fbc6 commit 346ac36

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed
30.6 KB
Loading
-16.6 KB
Binary file not shown.

docs/source/usage.rst

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,66 @@ Find out what a WMS has to offer. Service metadata:
99
.. code-block:: python
1010
1111
>>> from owslib.wms import WebMapService
12-
>>> wms = WebMapService('http://wms.jpl.nasa.gov/wms.cgi', version='1.1.1')
12+
>>> wms = WebMapService('https://mesonet.agron.iastate.edu/cgi-bin/mapserv/mapserv?map=/opt/iem/data/wms/goes/west_ir.map&SERVICE=WMS&REQUEST=GetCapabilities')
1313
>>> wms.identification.type
1414
'OGC:WMS'
1515
>>> wms.identification.version
1616
'1.1.1'
1717
>>> wms.identification.title
18-
'JPL Global Imagery Service'
18+
'IEM GOES IR WMS Service'
1919
>>> wms.identification.abstract
20-
'WMS Server maintained by JPL, worldwide satellite imagery.'
20+
'IEM generated CONUS composite of GOES IR Satellite.'
2121
2222
Available layers:
2323

2424
.. code-block:: python
2525
2626
>>> list(wms.contents)
27-
['global_mosaic', 'global_mosaic_base', 'us_landsat_wgs84', 'srtm_mag', 'daily_terra_721', 'daily_aqua_721', 'daily_terra_ndvi', 'daily_aqua_ndvi', 'daily_terra', 'daily_aqua', 'BMNG', 'modis', 'huemapped_srtm', 'srtmplus', 'worldwind_dem', 'us_ned', 'us_elevation', 'us_colordem']
27+
['goes_west_ir', 'west_ir_4km', 'west_ir_4km_gray']
2828
2929
Details of a layer:
3030

3131
.. code-block:: python
3232
33-
>>> wms['global_mosaic'].title
34-
'WMS Global Mosaic, pan sharpened'
35-
>>> wms['global_mosaic'].queryable
33+
>>> wms['goes_west_ir'].title
34+
'IEM GOES IR WMS Service'
35+
>>> wms['goes_west_ir'].queryable
3636
0
37-
>>> wms['global_mosaic'].opaque
37+
>>> wms['goes_west_ir'].opaque
3838
0
39-
>>> wms['global_mosaic'].boundingBox
40-
>>> wms['global_mosaic'].boundingBoxWGS84
41-
(-180.0, -60.0, 180.0, 84.0)
42-
>>> wms['global_mosaic'].crsOptions
43-
['EPSG:4326', 'AUTO:42003']
44-
>>> wms['global_mosaic'].styles
45-
{'pseudo_bright': {'title': 'Pseudo-color image (Uses IR and Visual bands, 542 mapping), gamma 1.5'}, 'pseudo': {'title': '(default) Pseudo-color image, pan sharpened (Uses IR and Visual bands, 542 mapping), gamma 1.5'}, 'visual': {'title': 'Real-color image, pan sharpened (Uses the visual bands, 321 mapping), gamma 1.5'}, 'pseudo_low': {'title': 'Pseudo-color image, pan sharpened (Uses IR and Visual bands, 542 mapping)'}, 'visual_low': {'title': 'Real-color image, pan sharpened (Uses the visual bands, 321 mapping)'}, 'visual_bright': {'title': 'Real-color image (Uses the visual bands, 321 mapping), gamma 1.5'}}
39+
>>> wms['goes_west_ir'].boundingBox
40+
(-126.0, 24.0, -66.0, 50.0, 'EPSG:4326')
41+
>>> wms['goes_west_ir'].boundingBoxWGS84
42+
(-126.0, 24.0, -66.0, 50.0)
43+
>>> wms['goes_west_ir'].crsOptions
44+
['EPSG:3857', 'EPSG:4326']
4645
4746
Available methods, their URLs, and available formats:
4847

4948
.. code-block:: python
5049
5150
>>> [op.name for op in wms.operations]
52-
['GetCapabilities', 'GetMap']
51+
['GetCapabilities', 'GetMap', 'GetFeatureInfo', 'DescribeLayer', 'GetLegendGraphic', 'GetStyles']
5352
>>> wms.getOperationByName('GetMap').methods
54-
{'Get': {'url': 'http://wms.jpl.nasa.gov/wms.cgi?'}}
53+
[{'type': 'Get', 'url': 'https://mesonet.agron.iastate.edu/cgi-bin/mapserv/mapserv?map=/opt/iem/data/wms/goes/west_ir.map&SERVICE=WMS&'}, {'type': 'Post', 'url': 'https://mesonet.agron.iastate.edu/cgi-bin/mapserv/mapserv?map=/opt/iem/data/wms/goes/west_ir.map&SERVICE=WMS&'}]
5554
>>> wms.getOperationByName('GetMap').formatOptions
56-
['image/jpeg', 'image/png', 'image/geotiff', 'image/tiff']
55+
['image/png', 'image/jpeg', 'image/png; mode=8bit', 'image/vnd.jpeg-png', 'image/vnd.jpeg-png8', 'application/x-pdf', 'image/svg+xml', 'image/tiff', 'application/json']
5756
5857
That's everything needed to make a request for imagery:
5958

6059
.. code-block:: python
6160
62-
>>> img = wms.getmap( layers=['global_mosaic'],
63-
... styles=['visual_bright'],
64-
... srs='EPSG:4326',
65-
... bbox=(-112, 36, -106, 41),
66-
... size=(300, 250),
67-
... format='image/jpeg',
68-
... transparent=True
69-
... )
70-
>>> out = open('jpl_mosaic_visb.jpg', 'wb')
71-
>>> out.write(img.read())
72-
>>> out.close()
61+
>>> img = wms.getmap(layers=['goes_west_ir'],
62+
size=(300, 250),
63+
bbox=(-126, 24, -66, 50),
64+
srs='EPSG:4326',
65+
format='image/png')
66+
>>> with open('iem_goes_ir.png', 'wb') as fh:
67+
... fh.write(img.read())
7368
7469
Result:
7570

76-
.. image:: _static/jpl_mosaic_visb.jpg
71+
.. image:: _static/iem_goes_ir.png
7772
:width: 300px
7873
:height: 250px
7974
:alt: WMS GetMap generated by OWSLib

0 commit comments

Comments
 (0)