Python Programming for GIS Data Processing in QGIS - Script, Module, Package, Library and Framework

preview_player
Показать описание


Script: A file with .py extension that contains variable, functions, classes etc that are intended to run when the file is executed

Module: it is 'Script' that is intended to be imported into another python script. It usually contains Python objects such as functions, classes, variables, constants, etc.
Example: this, antigravity, math, os, imp, importlib, re

Package: is a collection of 'Modules' in a folder that has a special file named '__init__.py'
Example: pandas, matplotlib, numpy, requests, beatifulsoup etc

Library: A complex 'Package' that contains useful functions
Example: same as packages including... TensorFlow, Keras, PyTorch, Scikit-Learn, Theano

Framework: A complex 'Library' that is used to fast track the development of an application
Example: Flask, Django, FastAPI, Web2Py, CherryPy, PyQt5, Tkinter, Kivy, wxPython, Libavg, PySimpleGUI, PyForms, Wax etc

---------------------- Working with Builtin Modules ------------------------------
Module/Package can only be imported once (however you can reload the import)
Use __file__ to see the module's file path

---------------------- Working with 3rd Party Modules ------------------------------
Archived: Unofficial Windows Binaries for Python Extension Packages -

Python modules/packages/libraries for GIS:-
GDAL/OGR, pyqgis, arcpy, pyproj, rsgislib, geopandas, folium, geemap, ipyleaflet, fiona, rasterio, shapely, pyshp, GeoDjango, geopy etc

---------------------- Creating your own Modules ------------------------------

Ways of importing a module
~ import moduleName
~ from moduleName import variable, function, class
~ from moduleName import *

Rename imported module using the 'as' keyword
~ import moduleName as mn
~ from moduleName import variable as v

Avoiding name collision
~ from math import sqrt
~ from cmath import sqrt

Absolute and Relative
Рекомендации по теме