I try to load a .osm
file into my QGIS project using python.
So I've write this code:
import processing
from qgis.core import *
# Creation of the .osm file, the QuickOSM plugin is needed.
bbox = '795078.7779580103, 795572.1303964029, 5908035.195114954, 5908380.196820124'
alg_params = {
'EXTENT': bbox,
'KEY': 'highway',
'SERVER': 'https://lz4.overpass-api.de/api/interpreter',
'TIMEOUT': 25,
'VALUE': ''
}
query = processing.run('quickosm:buildqueryextent', alg_params)
file = processing.run("native:filedownloader", {'URL':query['OUTPUT_URL'], 'OUTPUT':'TEMPORARY_OUTPUT'})
# Now I try to display the osm data:
vlayer = iface.addVectorLayer(file['OUTPUT'], "lines", "ogr")
The code do not crash, but since an .osm file can contains several different geometry the iface.addVectorLayer()
function open this windows:
And I need to manually select the geometry that I want to display (lines, multipolygons...). Is there a way to bypass this windows ? Is there a way to either load all the different geometry or to select the geometry that I'm interested in directly in the iface.addVectorLayer()
function ?