TransWikia.com

What's a provider in PyQGIS and how many types of providers exist?

Geographic Information Systems Asked by Casian Pavel on April 8, 2021

What’s a provider in PyQGIS and how many types of providers exist?

I am really not sure what a provider does. There is an example below from PyQGIS cookbook where a provider is used to load a QgsVectorLayer.

#get the path to the shapefile e.g. /home/project/data/ports.shp
path_to_airports_layer = "testdata/airports.shp"

#The format is:
vlayer = QgsVectorLayer(data_source, layer_name, provider_name)

vlayer = QgsVectorLayer(path_to_airports_layer, "Airports layer", "ogr")

2 Answers

Provider is a piece of code that reads and perhaps writes data from some source. The official providers you can find from the source code but there are also other providers that users have written for their special needs. Check these two directories:

https://github.com/qgis/QGIS/tree/master/src/core/providers

  • arcgis
  • ept
  • gdal
  • memory
  • meshmemory
  • ogr

https://github.com/qgis/QGIS/tree/master/src/providers

  • arcgisrest
  • db2
  • delimitedtext
  • geonode
  • gpx
  • grass
  • mdal
  • mssql
  • oracle
  • ows
  • pdal
  • postgres
  • spatialite
  • virtual
  • wcs
  • wfs
  • wms

GDAL and OGR providers can read any format that GDAL supports, that is https://gdal.org/drivers/raster/index.html and https://gdal.org/drivers/vector/index.html. It is possible to read some formats either with a native provider or by using GDAL/OGR (for example SpatiaLite).

Correct answer by user30184 on April 8, 2021

You can use QgsProviderRegistry.instance().providerList() to get the whole list of all available data provider keys.

# OUTPUT
['DB2', 'OAPIF', 'WFS', 'arcgisfeatureserver', 'arcgismapserver',
 'delimitedtext', 'gdal', 'geonode', 'gpx', 'grass', 'grassraster',
 'mdal', 'memory', 'mesh_memory', 'mssql', 'ogr', 'ows', 'postgres', 
 'postgresraster', 'spatialite', 'vectortile', 'virtual', 'wcs', 'wms']

Answered by Kadir Şahbaz on April 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP