Add example of integration with Quick Map Services
drnextgis opened this issue ยท 5 comments
Quick Map Services (QMS) is an open catalog of geodata sources since 2016 with over 1500 services (700+ are XYZ), more details here. It also provides REST API to consume data from it. I think it would be useful to have an example of integration between xyzservice and QMS. Something like this might be added to the documentation:
import folium
import requests
from xyzservices.lib import TileProvider
QMS_API = "https://qms.nextgis.com/api/v1/geoservices"
def get_service_details(service_name):
def get_service_id(service_name):
services = requests.get(f"{QMS_API}/?search={service_name}&type=tms&epsg=3857&limit=1")
services = services.json()
if services["results"]:
return services["results"][0]["id"]
service_id = get_service_id(service_name)
service_details = requests.get(f"{QMS_API}/{service_id}")
return service_details.json()
service_details = get_service_details("OpenTopoMap")
tiles = TileProvider(
name=service_details["name"],
url=service_details["url"],
attribution=service_details["copyright_text"]
)
folium.Map(
location=[53.4108, -2.9358],
tiles=tiles.build_url(),
attr=tiles.attribution,
)
It also might be used as a solution for #63:
service_details = get_service_details("Google Satellite")
google = TileProvider(
name=service_details["name"],
url=service_details["url"],
attribution="dummy"
)
folium.Map(
location=[53.4108, -2.9358],
tiles=google.build_url(),
attr=google.attribution,
)
@drnextgis this is great!
I would even be keen to turn it into a built-in method, something like TileProvider.from_qms(name)
. Would you like to add that? (if not, no problem, I can have a look at that at some point)?
Cool!
They have a {switch:a,b,c,d}
syntax for {s}
(see eg https://qms.nextgis.com/geoservices/567/), which is probably something we need to add support for.
Good catch. I guess we should replace {switch:a,b,c,d}
with {s}
and store "abcd" in our
"subdomains"under the hood in
from_qms`. Then we don't have to add specific support for this syntax elsewhere.
Leafmap now has an interactive GUI for searching and loading basemaps from xyzservices and QMS. See opengeos/leafmap#93
Here is an interactive streamlit app for searching and loading basemaps xyzservices and QMS.
https://share.streamlit.io/giswqs/streamlit-geospatial/app.py?page=Search+Basemaps