Open a QGIS Python Console and run this:
import processing
help( processing.runalg )
You will get:
Help on function runalg in module processing.tools.general:
runalg(algOrName, *args, **kwargs)
Which indicates us that by using processing.runalg()
, you're actually calling general.runalg()
.
Note that if you want to call general.runalg()
explicitly, you need to import the general
module from processing.tools
.
In summary, use whatever you want, just make sure you initialize Processing (Processing.initialize()
) before calling runalg()
if you're running a standalone PyQGIS script.
The definitive reference on the shapefile format is the ESRI Shapefile Technical Description.
It is misleading to describe the shx
as being an "index." Instead, it is the direct access offset file. There is no data in the shx
, only a clone of the first hundred bytes of the shp
(with the length block in bytes 24-27 sized for the shx
length) followed by record number and offset to the starting byte of that record in the shp
. The only location for attributes is the dbf
(which is standalone -- despite "knowledge" to the contrary, the shx
does not tie the shp
and dbf
, only record number does that).
It is possible for shapefiles to have "gaps" in the shp
which make the shx
indispensible, but in practice Esri tools will rewrite the entire shp
and shx
so that any gap created by editing records is removed. Under most conditions, it is possible to recover the shx
contents if it goes missing; the same cannot be said for the shp
or dbf
.
The naming of shp
and shx
is an artifact of the VFILE
variable width direct access module of the PrImeOS operating system, first ported by Esri to Unix, VAX/VMS, Data General, and IBM, then to Microsoft Windows. The sbn
/sbx
spatial index pair shares the same naming convention (though these are not documented within the shapefile specification). Within the original VFILE
FORTRAN library, only the base file was named, and the offset file with an x
terminal character just appeared at file creation.
Best Answer
So after reading through multiple docs and answers. This is my understanding:
QgsProcessingAlgorithm.postProcessAlgorithm()
You can do anything here related to canvas or not, literally almost anything. This runs first after theprocessAlgorithm
inQgsProcessingAlgorithm
. This is the part ofQgsProcessingAlgorithm
class.QgsProcessingLayerPostProcessorInterface.postProcessLayer()
On the other hand this is not part of theQgsProcessingAlgorithm
class and is run afterQgsProcessingAlgorithm
is completely finished. It does not do anything apart from attaching itspostProcessLayer
function to the layer on which it was added. (the function is not executed here)When QGIS natively outputs layers after the algorithm is finished, it will apply the
postProcessLayer
function as the last step.