Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spatialthoughts committed Aug 9, 2024
1 parent f2a96fa commit d69d9c7
Show file tree
Hide file tree
Showing 2 changed files with 230 additions and 53 deletions.
207 changes: 164 additions & 43 deletions docs/pyqgis-masterclass.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<title>PyQGIS Masterclass - Customizing QGIS with Python (Full Course Material)</title>

<script src="site_libs/header-attrs-2.10/header-attrs.js"></script>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<script src="site_libs/header-attrs-2.21/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
Expand Down Expand Up @@ -53,6 +53,7 @@
</style>



<style type="text/css">
code {
white-space: pre;
Expand All @@ -74,7 +75,7 @@
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
Expand Down Expand Up @@ -134,13 +135,20 @@
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var j = 0;
while (j < rules.length) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
j++;
continue;
}
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
if (rule.style.color === '' && rule.style.backgroundColor === '') {
j++;
continue;
}
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
Expand Down Expand Up @@ -176,6 +184,9 @@
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
Expand Down Expand Up @@ -232,11 +243,15 @@
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');

// mark it active
menuAnchor.tab('show');

// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
// mark the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
dropdown.addClass('active');
}

// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
Expand Down Expand Up @@ -265,25 +280,18 @@
border-radius: 4px;
}

.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "&#xe258;";
border: none;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
content: "\e258";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
border: none;
}

.tabset-dropdown > .nav-tabs > li.active {
Expand Down Expand Up @@ -327,7 +335,7 @@
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
Expand Down Expand Up @@ -365,6 +373,12 @@ <h4 class="author">Ujaval Gandhi</h4>
<li><a href="#introduction" id="toc-introduction">Introduction</a></li>
<li><a href="#get-the-data-package" id="toc-get-the-data-package">Get
the Data Package</a></li>
<li><a href="#get-the-course-videos" id="toc-get-the-course-videos">Get
the Course Videos</a>
<ul>
<li><a href="#youtube" id="toc-youtube">YouTube</a></li>
<li><a href="#vimeo" id="toc-vimeo">Vimeo</a></li>
</ul></li>
<li><a href="#installation-and-setting-up-the-environment"
id="toc-installation-and-setting-up-the-environment">Installation and
Setting up the Environment</a>
Expand Down Expand Up @@ -589,12 +603,16 @@ <h1>Introduction</h1>
Foundation for Spatial Analysis</a> course. We will build upon the
exercises covered in that course.</p>
<p><a
href="https://docs.google.com/presentation/d/1GT0c6jG3WmOZgsLuiIniEE9T1H8NJ5G6oemWX43VIUA/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/introduction.png" width="400"
alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=-nJ_8Ph_yPE&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE"
target="_blank"><img
src="https://img.youtube.com/vi/-nJ_8Ph_yPE/mqdefault.jpg"
alt="Watch the video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=-nJ_8Ph_yPE&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1GT0c6jG3WmOZgsLuiIniEE9T1H8NJ5G6oemWX43VIUA/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
target="_blank">Access the Presentation ↗</a></p>
</div>
<div id="get-the-data-package" class="section level1">
<h1>Get the Data Package</h1>
Expand All @@ -612,6 +630,26 @@ <h1>Get the Data Package</h1>
in our paid instructor-led classes.</p>
</blockquote>
</div>
<div id="get-the-course-videos" class="section level1">
<h1>Get the Course Videos</h1>
<p>The course is accompanied by a set of videos covering the all the
modules. These videos are recorded from our live instructor-led classes
and are edited to make them easier to consume for self-study. We have 2
versions of the videos:</p>
<div id="youtube" class="section level3">
<h3>YouTube</h3>
<p>We have created a YouTube Playlist with separate videos for each
notebook and exercise to enable effective online-learning. <a
href="https://www.youtube.com/playlist?list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE"
target="_blank">Access the YouTube Playlist ↗</a></p>
</div>
<div id="vimeo" class="section level3">
<h3>Vimeo</h3>
<p>We are also making combined full-length video for each module
available on Vimeo. These videos can be downloaded for offline learning.
<a href="" target="_blank">Access the Vimeo Playlist ↗</a></p>
</div>
</div>
<div id="installation-and-setting-up-the-environment"
class="section level1">
<h1>Installation and Setting up the Environment</h1>
Expand Down Expand Up @@ -645,6 +683,14 @@ <h2>Get a Text Editor</h2>
</div>
<div id="hello-world" class="section level1">
<h1>1. Hello World!</h1>
<p><a
href="https://www.youtube.com/watch?v=p60q4uiCqI0&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=3"
target="_blank"><img
src="https://img.youtube.com/vi/p60q4uiCqI0/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=p60q4uiCqI0&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=3"
target="_blank">Watch the Video ↗</a></p>
<p>QGIS Comes with a built-in <strong>Python Console</strong> and a code
editor where you can write and run Python code.</p>
<p>Go to <strong>Plugins → Python Console</strong> to open the
Expand All @@ -670,6 +716,14 @@ <h1>1. Hello World!</h1>
</div>
<div id="hello-pyqgis" class="section level1">
<h1>2. Hello PyQGIS!</h1>
<p><a
href="https://www.youtube.com/watch?v=7xNNpGoYK9Q&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=4"
target="_blank"><img
src="https://img.youtube.com/vi/7xNNpGoYK9Q/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=7xNNpGoYK9Q&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=4"
target="_blank">Watch the Video ↗</a></p>
<p>QGIS provides a Python API (Application Programming Interface),
commonly known as PyQGIS. The API is vast and very capable. Almost every
operation that you can do using QGIS - can be done using the API. This
Expand Down Expand Up @@ -749,9 +803,13 @@ <h1>3. Understanding Classes</h1>
we use PyQt or PyQGIS classes, it is executing the code in the C++
classes via the python bindings.</p>
<p><a
href="https://docs.google.com/presentation/d/1b4i1nEDR_uKJVu0IIqjoqrxeFD2a-tnj88JRXQW0JiA/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/classes.png" width="400"
alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=sUBnrV9McXk&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=5"
target="_blank"><img
src="https://img.youtube.com/vi/sUBnrV9McXk/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=sUBnrV9McXk&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=5"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1b4i1nEDR_uKJVu0IIqjoqrxeFD2a-tnj88JRXQW0JiA/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
Expand Down Expand Up @@ -972,9 +1030,13 @@ <h2>4.2 Distance Conversion</h2>
class="section level1">
<h1>5. Graphical User Interface (GUI) Programming Basics</h1>
<p><a
href="https://docs.google.com/presentation/d/1eK75jjfKx1IznIPrfcEljokLLQwkbNJ2DoStXDkF_f4/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/gui.png" width="400"
alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=g3Vwqg7WAHc&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=9"
target="_blank"><img
src="https://img.youtube.com/vi/g3Vwqg7WAHc/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=g3Vwqg7WAHc&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=9"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1eK75jjfKx1IznIPrfcEljokLLQwkbNJ2DoStXDkF_f4/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
Expand Down Expand Up @@ -1072,6 +1134,14 @@ <h2>6.1 QGIS Interface API (QgisInterface)</h2>
toolbars and other parts of the QGIS application. Python Console and
Plugins can use <code>iface</code> to access various parts of the QGIS
interface.</p>
<p><a
href="https://www.youtube.com/watch?v=rgOu6Qq_6Jg&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=10"
target="_blank"><img
src="https://img.youtube.com/vi/rgOu6Qq_6Jg/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=rgOu6Qq_6Jg&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=10"
target="_blank">Watch the Video ↗</a></p>
<div id="change-title-of-qgis-main-window" class="section level3">
<h3>6.1.1 Change Title of QGIS Main Window</h3>
<div class="sourceCode" id="cb18"><pre
Expand Down Expand Up @@ -1216,6 +1286,14 @@ <h2>6.2 QGIS Project API (QgsProject)</h2>
closed and a new project instance is created. You can get the current
instance of the QgsProject class by calling the
<strong><code>QgsProject.instance()</code></strong> method.</p>
<p><a
href="https://www.youtube.com/watch?v=32VVt60TO_A&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=14"
target="_blank"><img
src="https://img.youtube.com/vi/32VVt60TO_A/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=32VVt60TO_A&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=14"
target="_blank">Watch the Video ↗</a></p>
<div id="load-a-project" class="section level3">
<h3>6.2.1 Load a project</h3>
<div class="sourceCode" id="cb26"><pre
Expand Down Expand Up @@ -1314,6 +1392,14 @@ <h3>Exercise 4</h3>
</div>
<div id="running-python-code-at-qgis-launch" class="section level1">
<h1>7. Running Python Code at QGIS Launch</h1>
<p><a
href="https://www.youtube.com/watch?v=ZQNTKS2y4cE&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=16"
target="_blank"><img
src="https://img.youtube.com/vi/ZQNTKS2y4cE/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=ZQNTKS2y4cE&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=16"
target="_blank">Watch the Video ↗</a></p>
<p>It is possible to execute some PyQGIS code every time QGIS starts.
QGIS looks for a file named <code>startup.py</code> in the user’s Python
home directory, and if it is found, executes it. This file is very
Expand Down Expand Up @@ -1378,7 +1464,14 @@ <h1>8. Running Processing Algorithms</h1>
information about various options and techniques in the article <a
href="https://docs.qgis.org/testing/en/docs/user_manual/processing/console.html">Using
processing algorithms from the console</a> of the QGIS User Guide</p>
<p><img src="images/pyqgis/processing.png" width="75%" style="display: block; margin: auto;" /></p>
<p><a
href="https://www.youtube.com/watch?v=G4RfIsVAq4k&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=18"
target="_blank"><img
src="https://img.youtube.com/vi/G4RfIsVAq4k/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=G4RfIsVAq4k&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=18"
target="_blank">Watch the Video ↗</a></p>
<div id="creating-hillshade-from-a-dem" class="section level2">
<h2>8.1 Creating Hillshade from a DEM</h2>
<p>To use any Processing Algorithm via Python, you need to know how to
Expand Down Expand Up @@ -1513,6 +1606,14 @@ <h2>Exercise 6</h2>
</div>
<div id="assignment" class="section level1">
<h1>Assignment</h1>
<p><a
href="https://www.youtube.com/watch?v=McwUHDxOTik&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=21"
target="_blank"><img
src="https://img.youtube.com/vi/McwUHDxOTik/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=McwUHDxOTik&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=21"
target="_blank">Watch the Video ↗</a></p>
<p>The following assignment is designed to help you practice the skills
learnt so far in the course and explore the PyQGIS API.</p>
<p>Your task is to write a PyQGIS Script to show the average value of
Expand Down Expand Up @@ -1556,9 +1657,13 @@ <h1>9. Writing Plugins</h1>
write plugins using Python that can range from adding a simple button to
sophisticated tool-kits.</p>
<p><a
href="https://docs.google.com/presentation/d/1wegCN-_aQ6G4-VyyN-lO4o0n7Kj9kU-xT2jSz1wL5Ec/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/plugins.png" width="400"
alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=gzwhSOfknck&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=22"
target="_blank"><img
src="https://img.youtube.com/vi/gzwhSOfknck/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=gzwhSOfknck&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=22"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1wegCN-_aQ6G4-VyyN-lO4o0n7Kj9kU-xT2jSz1wL5Ec/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
Expand Down Expand Up @@ -1980,9 +2085,13 @@ <h2>11.3. Writing a Processing Script</h2>
with multiple inputs. This tutorial will show how to write a custom
python script that can be part of the Processing Framework in QGIS.</p>
<p><a
href="https://docs.google.com/presentation/d/1RraIdhQ0wv0ex66p_JGri7QzSYyLNU0elcxfxSGDS1Y/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/processing_scripts.png"
width="400" alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=ABERbwS_5rQ&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=30"
target="_blank"><img
src="https://img.youtube.com/vi/ABERbwS_5rQ/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=ABERbwS_5rQ&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=30"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1RraIdhQ0wv0ex66p_JGri7QzSYyLNU0elcxfxSGDS1Y/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
Expand Down Expand Up @@ -2377,9 +2486,13 @@ <h1>12. QGIS Actions</h1>
to add and distribute QGIS customizations without having to write
plugins.</p>
<p><a
href="https://docs.google.com/presentation/d/1wuGXVRBfZ2RxiiKY8zVs85JDKSgs0_NeZDS795hroCw/edit?usp=sharing"
target="_blank"><img src="images/pyqgis/actions.png" width="400"
alt="View Presentation" /></a></p>
href="https://www.youtube.com/watch?v=6LTTKjGabXM&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=33"
target="_blank"><img
src="https://img.youtube.com/vi/6LTTKjGabXM/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=6LTTKjGabXM&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=33"
target="_blank">Watch the Video ↗</a></p>
<p><a
href="https://docs.google.com/presentation/d/1wuGXVRBfZ2RxiiKY8zVs85JDKSgs0_NeZDS795hroCw/edit?usp=sharing"
target="_blank">View the Presentation ↗</a></p>
Expand Down Expand Up @@ -2707,6 +2820,14 @@ <h1>13. Writing Standalone Python Scripts</h1>
server without human intervention. Let’s use some QGIS processing
algorithms to carry out zonal statistics using a standalone python
script.</p>
<p><a
href="https://www.youtube.com/watch?v=qLgP_-BAwME&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=38"
target="_blank"><img
src="https://img.youtube.com/vi/qLgP_-BAwME/mqdefault.jpg"
alt="Watch the Video" /></a></p>
<p><a
href="https://www.youtube.com/watch?v=qLgP_-BAwME&amp;list=PLppGmFLhQ1HKKnk3riKNyOxb-3MTI-7zE&amp;index=38"
target="_blank">Watch the Video ↗</a></p>
<p>Create a new file with the code below and save it as
<code>zonal_stats.py</code>.</p>
<div class="sourceCode" id="cb58"><pre
Expand Down
Loading

0 comments on commit d69d9c7

Please sign in to comment.