2017-06-11 19:39:08 +00:00
{
"cells": [
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 2,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [],
"source": [
"from owslib.wms import WebMapService"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 3,
2017-06-11 19:39:08 +00:00
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"wms = WebMapService('http://cartes.geogratis.gc.ca/wms/elevation_fr?', version='1.3.0')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Propriétés du service web WMS"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 4,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"'WMS'"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 4,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms.identification.type"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 5,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"'1.3.0'"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 5,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms.identification.version"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 6,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
2017-06-24 20:23:55 +00:00
"\"Service de cartographie Web (WMS) pour les données d'élévation\""
2017-06-11 19:39:08 +00:00
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 6,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms.identification.title"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 7,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
2017-06-24 20:23:55 +00:00
"\"Ressources naturelles Canada offre un accès aux données d'élévation par le biais d'un service de cartographie Web communément appelé Web Mapping Service (WMS) dont les spécifications sont définies par l'Open Geospatial Consortium (OGC).\""
2017-06-11 19:39:08 +00:00
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 7,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms.identification.abstract"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 8,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"['WMS-Elevation',\n",
" 'cdsm.color-shaded-relief',\n",
" 'cdsm.color-shaded-relief.legend',\n",
" 'cdem.color-shaded-relief',\n",
" 'cdem.color-shaded-relief.legend']"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 8,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(wms.contents)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Propriétés d'une couche du service web WMS"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 9,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
2017-06-24 20:23:55 +00:00
"\"Service de cartographie Web (WMS) pour les données d'élévation\""
2017-06-11 19:39:08 +00:00
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 9,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms['WMS-Elevation'].title"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 10,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"(-180.0, -90.0, 180.0, 90.0)"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 10,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms['WMS-Elevation'].boundingBoxWGS84"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 11,
2017-06-11 19:39:08 +00:00
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
2017-06-24 20:23:55 +00:00
"['EPSG:26708',\n",
" 'EPSG:102018',\n",
" 'EPSG:32182',\n",
" 'EPSG:26718',\n",
" 'EPSG:3575',\n",
" 'EPSG:26922',\n",
" 'EPSG:26919',\n",
" 'EPSG:54030',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:32186',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:102008',\n",
" 'EPSG:26714',\n",
" 'EPSG:41001',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26709',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:32184',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26909',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:54016',\n",
" 'EPSG:26712',\n",
" 'EPSG:54004',\n",
" 'EPSG:32189',\n",
" 'EPSG:3857',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26716',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:3579',\n",
" 'EPSG:32185',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26711',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:2952',\n",
" 'EPSG:3574',\n",
" 'EPSG:32193',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26713',\n",
" 'EPSG:32187',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:2295',\n",
" 'EPSG:2294',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:32188',\n",
" 'EPSG:3578',\n",
" 'EPSG:3573',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:42304',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:102002',\n",
" 'EPSG:3400',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:3395',\n",
" 'EPSG:32183',\n",
" 'EPSG:26917',\n",
" 'EPSG:104306',\n",
" 'EPSG:53016',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:102017',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:26707',\n",
" 'EPSG:102016',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:2019',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:32181',\n",
" 'EPSG:3979',\n",
" 'EPSG:26907',\n",
" 'EPSG:102185',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:4326',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:3401',\n",
" 'EPSG:3799',\n",
" 'EPSG:26911',\n",
" 'EPSG:26912',\n",
" 'EPSG:54009',\n",
" 'EPSG:26721',\n",
" 'EPSG:26908',\n",
" 'EPSG:102100',\n",
" 'EPSG:26717',\n",
" 'EPSG:3978',\n",
" 'EPSG:32191',\n",
" 'EPSG:26914',\n",
" 'EPSG:32194',\n",
" 'EPSG:32197',\n",
" 'EPSG:26710',\n",
" 'EPSG:32198',\n",
" 'EPSG:3576',\n",
" 'EPSG:54003',\n",
" 'EPSG:102009',\n",
" 'EPSG:26918',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:42101',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:26916',\n",
" 'EPSG:4269',\n",
" 'EPSG:26722',\n",
" 'EPSG:3571',\n",
" 'EPSG:26719',\n",
" 'EPSG:54008',\n",
" 'EPSG:4617',\n",
" 'EPSG:26910',\n",
" 'EPSG:26715',\n",
" 'EPSG:900913',\n",
" 'EPSG:32196',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26920',\n",
2017-06-24 20:23:55 +00:00
" 'EPSG:32195',\n",
" 'EPSG:32190',\n",
" 'EPSG:32192',\n",
" 'EPSG:3572',\n",
" 'EPSG:102184',\n",
" 'EPSG:26915',\n",
" 'EPSG:26720',\n",
" 'EPSG:26913',\n",
2017-06-11 19:39:08 +00:00
" 'EPSG:26921']"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 11,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms['WMS-Elevation'].crsOptions"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 12,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"{}"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 12,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms['WMS-Elevation'].styles"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 13,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"['GetCapabilities', 'GetMap', 'GetFeatureInfo', 'GetLegendGraphic']"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 13,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[op.name for op in wms.operations]"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 14,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [
{
"data": {
"text/plain": [
"['image/png', 'image/gif', 'image/jpeg', 'image/png; mode=8bit', 'image/tiff']"
]
},
2017-06-24 20:23:55 +00:00
"execution_count": 14,
2017-06-11 19:39:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wms.getOperationByName('GetMap').formatOptions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exemple de requête"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 15,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [],
"source": [
"img = wms.getmap(layers=['WMS-Elevation'],\n",
" srs='EPSG:4269',\n",
" bbox=(-72.25,-71.25,46.25,47.25),\n",
" size=(450,450),\n",
" format='image/png',\n",
" transparent=True)"
]
},
{
"cell_type": "code",
2017-06-24 20:23:55 +00:00
"execution_count": 16,
"metadata": {},
2017-06-11 19:39:08 +00:00
"outputs": [],
"source": [
"out = open('canada-wms.png', 'wb')\n",
"out.write(img.read())\n",
"out.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](canada-cdsm.png)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
2017-06-24 20:23:55 +00:00
"display_name": "Python 3",
2017-06-11 19:39:08 +00:00
"language": "python",
2017-06-24 20:23:55 +00:00
"name": "python3"
2017-06-11 19:39:08 +00:00
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
2017-06-24 20:23:55 +00:00
"version": 3
2017-06-11 19:39:08 +00:00
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
2017-06-24 20:23:55 +00:00
"pygments_lexer": "ipython3",
"version": "3.6.1"
2017-06-11 19:39:08 +00:00
},
"widgets": {
"state": {
"bc6d60e3e9e349c2befeef1fbd33b91d": {
"views": [
{
"cell_index": 16
}
]
}
},
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 1
}