Can I download the data from a webmap made available from leaflet? I am referring to these dataset (https://www.vectorbase.org/popbio/map/), for which I wish to download the data for Europe? Is there a way to import these data into QGIS providing the link of the website?
[GIS] Download data from webmap made with leaflet
leafletqgis
Related Solutions
You can run the following in the QGIS Python console to write a GeoJSON
from urllib.request import urlopen
import json
url = "https://api.fixmyberlin.de/api/projects?page_size=200"
html = urlopen(url)
data = json.load(html)
geojson = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"id": bike_path['id'],
"url": bike_path['url'],
"project_key": bike_path['project_key'],
"title": bike_path['title'],
"description": bike_path['description'],
"short_description": bike_path['short_description'],
"category": bike_path['category'],
"street_name": bike_path['street_name'],
"borough": bike_path['borough'],
"side": bike_path['side'],
"costs": bike_path['costs'],
"draft_submitted": bike_path['draft_submitted'],
"construction_started": bike_path['construction_started'],
"construction_completed": bike_path['construction_completed'],
"phase": bike_path['phase'],
"responsible": bike_path['responsible'],
"external_url": bike_path['external_url'],
"cross_section": bike_path['cross_section'],
"faq": bike_path['faq'],
"length": bike_path['length'],
"photos": bike_path['photos'],
"likes": bike_path['likes'],
"liked_by_user": bike_path['liked_by_user']
},
"geometry": bike_path["geometry"]
} for bike_path in data['results']]
}
with open('/tmp/my_geojson.geojson', 'w', encoding='utf-8') as outfile:
json.dump(geojson, outfile)
PS: I do not manage the pagination here
You can change the path /tmp/my_geojson.geojson
according to your need. Then, open the file as a vector layer in QGIS and it works.
An overview below with OSM background
That URL is not a WMS server, its a web page.
The web page has a Javascript application running that produces the map.
The map contains several layers, including the base map (land/sea) and a rainfall overlay.
The rainfall overlay appears to be coming from nowcoast.noaa.org, as an ESRI API map via leaflet.
However nowcoast.noaa.org do have some WMS services:
https://nowcoast.noaa.gov/help/#!section=map-service-list
So if you can find the service you want in the list and construct the URL correctly you should be able to map it.
For example, this URL:
url="https://nowcoast.noaa.gov/arcgis/services/nowcoast/analysis_meteohydro_sfc_qpe_time/MapServer/WMSServer"
works with:
addWMSTiles(url,layers="1")
or if you want transparency:
addWMSTiles(url, layers="1", options=list(format="image/png", transparent="true"))
The "layers" parameter can let you get more than one layer. There's a hierarchical structure which is in the XML of the GetCapabilities document you linked to, and you can see it with QGIS' WMS layers dialog:
The "layers" numbers here are the "name" column, so the 24h image seems to be layer 9 (you can check this in the XML):
addWMSTiles(url, layers="9", options=list(format="image/png", transparent="true"))
might be what you want.
Best Answer
In general, yes, in theory, yes, in practice, yes with a bit of work. There's no general general solution because you can't know how the data is coming from the server. The solution involves looking at the underlying Javascript and seeing what it does. Chances are it will be an AJAX call to a server that returns a geoJSON data set, but it could literally be anything. If AJAX and geoJSON mean nothing to you then I doubt you'll be able to write something to do it for any given site.
That said, the site you reference has a big fat "Downloads" button which is clearly the recommended way to get the data you want rather than trying to reverse engineer their web map system. Use that.