get_serviceο
- add_wms.get_service(url, service_type='wms', rest_API=False, maxzoom=19, **kwargs)ο
Get a object that can be used to add WMS, WMTS or XYZ services based on a GetCapabilities-link or a link to a ArcGIS REST API
The general usage is as follows (see examples below for more details):
>>> m = Maps() >>> s = m.add_wms.get_service(...) >>> wms = s.add_layer.<...> >>> wms.set_extent_to_bbox() # set the extent of the map to the wms-extent >>> wms(transparent=True) # add the service to the map
- Parameters:
url (str) β The service-url
service_type (str) β
The type of service (either βwmsβ or βwmtsβ)
βwmsβ : url represents a link to a GetCapabilities.xml file for a WebMap service
βwmtsβ : same as βwmsβ but for a WebMapTile service
βxyzβ : A direct link to a xyz-TileServer (the name of the layer is set to βxyz_layerβ)
The url can be provided either as a string of the form:
>>> "https://.../{z}/{x}/{y}.png"
Or (for non-standard urls) as a function with the following call-signature:
>>> def url(x, y, z): >>> return "the url with x, y, z replaced by the arguments"
See the examples below for more details on common use-cases.
rest_API (bool, optional) β
ONLY relevant if service_type is either βwmsβ or βwmtsβ!
Indicator if a GetCapabilities link (True) or a link to a rest-API is provided (False). The default is False
maxzoom (int) β
ONLY relevant if service_type=βxyzβ!
The maximum zoom-level available (to avoid http-request errors) for too high zoom levels. The default is 19.
kwargs β
Additional keyword arguments passed to owslib.WebMapService(). (only relevant if type is βwmsβ or βwmtsβ)
For example: version=1.3.0
- Returns:
service β An object that behaves just like m.add_wms.<service> and provides easy-access to available WMS layers
- Return type:
_WebServiceCollection
Examples
WMS Example:
Copernicus Global Land Mosaics for Austria, Germany and Slovenia from Sentinel-2
>>> url = "https://s2gm-wms.brockmann-consult.de/cgi-bin/qgis_mapserv.fcgi?MAP=/home/qgis/projects/s2gm-wms_mosaics_vrt.qgs&service=WMS&request=GetCapabilities&version=1.1.1" >>> s = m.add_wms.get_service(url, "wms")
Web Map Services of the city of Vienna (Austria)
>>> url = "https://data.wien.gv.at/daten/geo?version=1.3.0&service=WMS&request=GetCapabilities" >>> s = m.add_wms.get_service(url, "wms")
WMTS Example:
WMTS service for NASA GIBS datasets
>>> url = https://gibs.earthdata.nasa.gov/wmts/epsg4326/all/1.0.0/WMTSCapabilities.xml >>> s = m.add_wms.get_service(url, "wmts")
Rest API Example:
Interface to the ArcGIS REST Services Directory for the Austrian Federal Institute of Geology (Geologische Bundesanstalt)
>>> url = "https://gisgba.geologie.ac.at/arcgis/rest/services" >>> s = m.add_wms.get_service(url, "wms", rest_API=True)
XYZ Example:
OpenStreetMap Tiles (https://wiki.openstreetmap.org/wiki/Tiles)
>>> url = r"https://tile.openstreetmap.org/{z}/{x}/{y}.png" >>> s = m.add_wms.get_service(url, "xyz")
>>> def url(x, y, z): >>> return rf"https://tile.openstreetmap.org/{z}/{x}/{y}.png" >>> s = m.add_wms.get_service(url, "xyz")