Skip to content

Instantly share code, notes, and snippets.

@procrastinatio
Created March 24, 2017 15:27
Show Gist options
  • Save procrastinatio/92d6034390b569b9102f1b687c5bd9a4 to your computer and use it in GitHub Desktop.
Save procrastinatio/92d6034390b569b9102f1b687c5bd9a4 to your computer and use it in GitHub Desktop.
Testing Geneva's WMS services
#!/usr/bin/env python
import owslib
from owslib.wms import WebMapService
import requests
import lxml
urls= ['https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_01/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_02/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_03/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_04/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_GEOSERVICEDATA/MapServer/WMSServer',
'https://ge.ch/sitgags2/rest/services/RASTER']
for url in urls:
print url,
try:
wms = WebMapService(url, version='1.1.1')
#print wms.identification.type
print "title={}, layers={}".format(wms.identification.title, ",".join([wms[i].title for i in wms.contents]))
except owslib.util.ServiceException:
print "not an WMS service"
except requests.packages.urllib3.exceptions.ConnectTimeoutError as e:
print "Connection timeout", e
except lxml.etree.XMLSyntaxError as e:
print "XML parse error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment