(Glossary, in progress...)

  • Constructor method: to create an instance from a class. Example: class dog. An instance of class Dog is my_dog; For instance, my_dog=Dog(“Spot”, “brown”, “big”). my_dog.name returns the value of the attribute name ("Spot"); my_dog.sit() applies method "sit" to my_dog. "sit" is a function; the empty argument refers to the instance itself.
  • CRS. to define the project's CRS, e.g. my_crs=QgsCoordinateReferenceSystem(3763), followed by QgsProject.instance().setCrs(my_crs)
  • exec(open(ps.path.join(folder,'funcoes-auxiliares.py').encode('utf-8')).read()) : load auxiliary script
  • encoding: ASCII, Unicode, utf-8: see this page for a simple explanation. For instance, mylayer.dataProvider().setEncoding('utf-8') sets the encoding for mylayer
  • gdal data provider for rasters. GDAL is used for reading, writing and transforming raster data. Package osgeo
  • GDAL/OGR is an open source geospatial data IO library with a set of command line utilities
  • GeoPackage is an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial information.

    The GeoPackage Encoding Standard describes a set of conventions for storing the following within an SQLite database (vector features; tile matrix sets of imagery and raster maps at various scales; attributes i.e. non-spatial data; extensions. With Geopackage we have the possibility to work with our data in a file-based database environment that supports SQL with a variety of spatial functions.

  • geospatial open sources libraires:e.g. GDAL/OGR, PROJ, GEOS
  • A geotransform is an affine transformation from the image coordinate space (row, column), also known as (pixel, line) to the georeferenced coordinate space (projected or geographic coordinates). A geotransform consists in a set of 6 coefficients: GT(0) x-coordinate of the upper-left corner of the upper-left pixel. GT(1) w-e pixel resolution / pixel width. GT(2) row rotation (typically zero). GT(3) y-coordinate of the upper-left corner of the upper-left pixel. GT(4) column rotation (typically zero). GT(5) n-s pixel resolution / pixel height (negative value for a north-up image).

  • iface : it’s a “hook” to access QGIS interface: It is a reference to an instance of class QgisInterface;
    • gives access to the map canvas with iface.mapCanvas() -- area of the screen where the map is drawn;
    • iface.mapCanvas().layers() is a list very similar to QgsProject.instance().mapLayers().values(), but iface.mapCanvas().layers() only lists active layers
    • iface.mapCanvas().currentLayer() -- current selected layer;
    • iface.mapCanvas().layers()  returns all layers
    • iface.addVectorLayer(fn,'layer_label','ogr') is a shortcut for QgsProject.instance().addMapLayer(lyr), where lyr is a QgsVectorLayer; adds layer to interface/project
    • iface.layerTreeView().refreshLayerSymbology(mylayer.id()) # Refresh layer's symbology in Layer Tree
    • read rasters: either addRasterLayer(self, rasterLayerPath: str, baseName: str = '') or addRasterLayer(self, url: str, layerName: str, providerKey: str)
      • iface.addRasterLayer(uri,name,providerKey) is the same as QgsProject.instance().addMapLayer(QgsRasterLayer(uri,name,providerKey))
      • iface.addRasterLayer('filename.tif') to load a tif file
  • Interpolation modes (raster layers)
    • linear (Interpolated): the color is linearly interpolated from the color map entries above and below the pixel value

    • discrete (Discrete): the color is taken from the closest color map entry with equal or higher value

    • exact (Exact): the color is not interpolated, only pixels with values equal to color map entries will be drawn

  • isinstance(x,y) tests if x is an instance of object class b
  • iterator
  • layers: see vector layers and raster layers
  • map canvas: The Map canvas widget is probably the most important widget within QGIS because it shows the map composed from overlaid map layers and allows interaction with the map and layers. The canvas always shows a part of the map defined by the current canvas extent. The interaction is done through the use of map tools: there are tools for panning, zooming, identifying layers, measuring, vector editing and others. Similar to other graphics programs, there is always one tool active and the user can switch between the available tools. https://docs.qgis.org/3.16/en/docs/pyqgis_developer_cookbook/canvas.html
  • map canvas access: iface.mapCanvas() or QgsMapCanvas(); they are (two different) instances of QgsMapCanvas
  • ogr: data provider for vector data.  OGR  is used for reading, writing and transforming vector data. Package osgeo
  • project: currently active project is accessible with myproj=QgsProject.instance(); note: the qgis project is a "singleton" object;
    • myproj.mapLayersByName("name_layer") returns a list;
    • see more in QgsProject.instance()
  • python -m : When you use the -m command-line flag, Python will import a module or package for you, then run it as a script. When you don't use the -m flag, the file you named is run as just a script. (https://stackoverflow.com/questions/22241420/execution-of-python-code-with-m-option-or-not; https://docs.python.org/3/using/cmdline.html)
  • PyPi: The Python Package Index (PyPI) is a repository of software for the Python programming language.(https://pypi.org/)
  • PIP is a package management system used to install and manage software packages written in Python. It stands for “preferred installer program” or "Pip Installs Packages.” PIP for Python is a utility to manage PyPI package installations from the command line.
  • Package, module, script: Package= directory with modules; Module: directory with scripts; Scripts: text file with Python code; normally each scripts defines a class, attributes and methods
  • Qt: framework for creating graphical user interfaces (GUI); written in C++. PyQt5 is a package to access Qt5 classes.
  • QgsProject.instance()
    • QgsProject.instance().homePath() returns project path
    • QgsProject.instance().addMapLayer(lyr), where lyr is a QgsVectorLayer; adds layer to interface/project
  • QgsVectorLayer(fn,'layer_label','ogr'): ogr is the dataProvider; creates layer
  • Raster layer: see iface
  • Renderer: method to render the data
    • singleSymbol, categorizedSymbol, graduateSymbol.
    • summary of renderer: print(mylayer.renderer().dump())
    • qgis.core.QgsSingleSymbolRenderer(symbol: QgsSymbol); QgsSymbol is defined e.g. by symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PointGeometry); Properties like color, size, shape, etc can then be changed; then the renderer is reset by mylayer.renderer().setSymbol(symbol)
    • qgis.core.QgsCategorizedSymbolRenderer(attrName: str = '', categories: Iterable[QgsRendererCategory] = []); attname is the field name; the 2nd argument is a list of QgsRendererCategory with three arguments: category, QgsSymbol, and label. E.g. cat1=QgsRendererCategory('Improdutivos', symbol1, 'Solos improdutivos') # category, symbol, label.
    • qgis.core.QgsGraduatedSymbolRenderer(attrName: str = '', ranges: Iterable[QgsRendererRange] = []); QgsRendererRange. Each class is defined by myRange1 = QgsRendererRange(myMin, myMax, mySymbol, myLabel);The renderer is defined by renderer = QgsGraduatedSymbolRenderer(myfield, myRangeList), where myRangeList is a list of QgsRendererRange. Finally, mylayer.setRenderer(renderer)
  • Symbol (of a layer)
    • Create from scratch with a constructer method like symbol=QgsMarkerSymbol.createSimple({'name':'square','color':'red'}) , followed by lyr.renderer().setSymbol(symbol), or
    • Modify existing symbol with, e.g., QgsSymbol.defaultSymbol(lyr.geometryType()) , followed by symbol.setColor(QColor(color)), where lyr is a layer, and color a color like "red"
  • URL, URI: a URL (uniform resource locator) is the locator of a resource (e.g. https://..., ftp://...). The URI is the identifier of the resource and it can just happen to be a locator.
  • Vector layer methods: consider the layer returned by lyrs=myproj.mapLayersByName("faixasIntExt") and lyr=lyrs[0] , 1st of the list; lyr is of class QgsVectorLayer:
    • lyr.id() layer's id
    • myproj.removeMapLayer(lyr.id()) removes layer lyr from project
    • lyr.sourceName() returns layer name
    • lyr.featureCount() returns number of features
    • lyr.getFeatures() returns an iterator to the features
    • lyr.selectedFeatures() returns selected features
    • lyr.isValid()
    • lyr.setOpacity(alpha), followed by lyr.triggerRepaint(), alpha between 0 (transparent) and 1(opaque) [tested]
  • WMS (Web Map Service), WFS (Web Feature Service), and WCS (Web Coverage Service) are three web service standards from the Open Geospatial Consortium (OGC). These allow web clients to query and receive geographic information in the form of image, vector, or coverage data. https://www.winwaed.com/blog/2009/02/09/overview-wms-wfs-wcs/
  • The XYZ protocol describes how a mapping client (often from within a browser) can access tiled imagery.