Table of Contents for
QGIS: Becoming a GIS Power User

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition QGIS: Becoming a GIS Power User by Alexander Bruy Published by Packt Publishing, 2017
  1. Cover
  2. Table of Contents
  3. QGIS: Becoming a GIS Power User
  4. QGIS: Becoming a GIS Power User
  5. QGIS: Becoming a GIS Power User
  6. Credits
  7. Preface
  8. What you need for this learning path
  9. Who this learning path is for
  10. Reader feedback
  11. Customer support
  12. 1. Module 1
  13. 1. Getting Started with QGIS
  14. Running QGIS for the first time
  15. Introducing the QGIS user interface
  16. Finding help and reporting issues
  17. Summary
  18. 2. Viewing Spatial Data
  19. Dealing with coordinate reference systems
  20. Loading raster files
  21. Loading data from databases
  22. Loading data from OGC web services
  23. Styling raster layers
  24. Styling vector layers
  25. Loading background maps
  26. Dealing with project files
  27. Summary
  28. 3. Data Creation and Editing
  29. Working with feature selection tools
  30. Editing vector geometries
  31. Using measuring tools
  32. Editing attributes
  33. Reprojecting and converting vector and raster data
  34. Joining tabular data
  35. Using temporary scratch layers
  36. Checking for topological errors and fixing them
  37. Adding data to spatial databases
  38. Summary
  39. 4. Spatial Analysis
  40. Combining raster and vector data
  41. Vector and raster analysis with Processing
  42. Leveraging the power of spatial databases
  43. Summary
  44. 5. Creating Great Maps
  45. Labeling
  46. Designing print maps
  47. Presenting your maps online
  48. Summary
  49. 6. Extending QGIS with Python
  50. Getting to know the Python Console
  51. Creating custom geoprocessing scripts using Python
  52. Developing your first plugin
  53. Summary
  54. 2. Module 2
  55. 1. Exploring Places – from Concept to Interface
  56. Acquiring data for geospatial applications
  57. Visualizing GIS data
  58. The basemap
  59. Summary
  60. 2. Identifying the Best Places
  61. Raster analysis
  62. Publishing the results as a web application
  63. Summary
  64. 3. Discovering Physical Relationships
  65. Spatial join for a performant operational layer interaction
  66. The CartoDB platform
  67. Leaflet and an external API: CartoDB SQL
  68. Summary
  69. 4. Finding the Best Way to Get There
  70. OpenStreetMap data for topology
  71. Database importing and topological relationships
  72. Creating the travel time isochron polygons
  73. Generating the shortest paths for all students
  74. Web applications – creating safe corridors
  75. Summary
  76. 5. Demonstrating Change
  77. TopoJSON
  78. The D3 data visualization library
  79. Summary
  80. 6. Estimating Unknown Values
  81. Interpolated model values
  82. A dynamic web application – OpenLayers AJAX with Python and SpatiaLite
  83. Summary
  84. 7. Mapping for Enterprises and Communities
  85. The cartographic rendering of geospatial data – MBTiles and UTFGrid
  86. Interacting with Mapbox services
  87. Putting it all together
  88. Going further – local MBTiles hosting with TileStream
  89. Summary
  90. 3. Module 3
  91. 1. Data Input and Output
  92. Finding geospatial data on your computer
  93. Describing data sources
  94. Importing data from text files
  95. Importing KML/KMZ files
  96. Importing DXF/DWG files
  97. Opening a NetCDF file
  98. Saving a vector layer
  99. Saving a raster layer
  100. Reprojecting a layer
  101. Batch format conversion
  102. Batch reprojection
  103. Loading vector layers into SpatiaLite
  104. Loading vector layers into PostGIS
  105. 2. Data Management
  106. Joining layer data
  107. Cleaning up the attribute table
  108. Configuring relations
  109. Joining tables in databases
  110. Creating views in SpatiaLite
  111. Creating views in PostGIS
  112. Creating spatial indexes
  113. Georeferencing rasters
  114. Georeferencing vector layers
  115. Creating raster overviews (pyramids)
  116. Building virtual rasters (catalogs)
  117. 3. Common Data Preprocessing Steps
  118. Converting points to lines to polygons and back – QGIS
  119. Converting points to lines to polygons and back – SpatiaLite
  120. Converting points to lines to polygons and back – PostGIS
  121. Cropping rasters
  122. Clipping vectors
  123. Extracting vectors
  124. Converting rasters to vectors
  125. Converting vectors to rasters
  126. Building DateTime strings
  127. Geotagging photos
  128. 4. Data Exploration
  129. Listing unique values in a column
  130. Exploring numeric value distribution in a column
  131. Exploring spatiotemporal vector data using Time Manager
  132. Creating animations using Time Manager
  133. Designing time-dependent styles
  134. Loading BaseMaps with the QuickMapServices plugin
  135. Loading BaseMaps with the OpenLayers plugin
  136. Viewing geotagged photos
  137. 5. Classic Vector Analysis
  138. Selecting optimum sites
  139. Dasymetric mapping
  140. Calculating regional statistics
  141. Estimating density heatmaps
  142. Estimating values based on samples
  143. 6. Network Analysis
  144. Creating a simple routing network
  145. Calculating the shortest paths using the Road graph plugin
  146. Routing with one-way streets in the Road graph plugin
  147. Calculating the shortest paths with the QGIS network analysis library
  148. Routing point sequences
  149. Automating multiple route computation using batch processing
  150. Matching points to the nearest line
  151. Creating a routing network for pgRouting
  152. Visualizing the pgRouting results in QGIS
  153. Using the pgRoutingLayer plugin for convenience
  154. Getting network data from the OSM
  155. 7. Raster Analysis I
  156. Using the raster calculator
  157. Preparing elevation data
  158. Calculating a slope
  159. Calculating a hillshade layer
  160. Analyzing hydrology
  161. Calculating a topographic index
  162. Automating analysis tasks using the graphical modeler
  163. 8. Raster Analysis II
  164. Calculating NDVI
  165. Handling null values
  166. Setting extents with masks
  167. Sampling a raster layer
  168. Visualizing multispectral layers
  169. Modifying and reclassifying values in raster layers
  170. Performing supervised classification of raster layers
  171. 9. QGIS and the Web
  172. Using web services
  173. Using WFS and WFS-T
  174. Searching CSW
  175. Using WMS and WMS Tiles
  176. Using WCS
  177. Using GDAL
  178. Serving web maps with the QGIS server
  179. Scale-dependent rendering
  180. Hooking up web clients
  181. Managing GeoServer from QGIS
  182. 10. Cartography Tips
  183. Using Rule Based Rendering
  184. Handling transparencies
  185. Understanding the feature and layer blending modes
  186. Saving and loading styles
  187. Configuring data-defined labels
  188. Creating custom SVG graphics
  189. Making pretty graticules in any projection
  190. Making useful graticules in printed maps
  191. Creating a map series using Atlas
  192. 11. Extending QGIS
  193. Defining custom projections
  194. Working near the dateline
  195. Working offline
  196. Using the QspatiaLite plugin
  197. Adding plugins with Python dependencies
  198. Using the Python console
  199. Writing Processing algorithms
  200. Writing QGIS plugins
  201. Using external tools
  202. 12. Up and Coming
  203. Preparing LiDAR data
  204. Opening File Geodatabases with the OpenFileGDB driver
  205. Using Geopackages
  206. The PostGIS Topology Editor plugin
  207. The Topology Checker plugin
  208. GRASS Topology tools
  209. Hunting for bugs
  210. Reporting bugs
  211. Bibliography
  212. Index

Using external tools

While QGIS itself is a great and functional program, sometimes it is better to use more suitable tools to perform some simple or complex actions. This recipe shows you how to use some of these third-party tools.

Getting ready

To follow this recipe, you will need a btnmeatrack_2014-05-22_13-35-40.nmea file from the book dataset. We will also use the cookbook.db SpatiaLite database that we created in the Loading vector layers into SpatiaLite recipe in Chapter 1, Data Input and Output, and the PostgreSQL database, which we developed in Chapter 6, Network Analysis.

Besides this, don't forget to install GPSBabel (usually this comes with QGIS), spatialite-gui, and pgAdmin (these should be installed manually).

How to do it…

First we will convert NMEA data to GPX format with GPSBabel, then learn how to use SpatiaLite GUI tools and pgAdmin to work with databases.

GPSBabel

GPSBabel is a command-line tool to manipulate, convert, and process GPS data (waypoints, tracks, and routes) in different formats.

To convert a file from the NMEA format to more common GPX, follows these steps:

  1. Open the command prompt and go to the directory where the btnmeatrack_2014-05-22_13-35-40.nmea file is located. Usually, this can be done with the cd command, for example, if the file is located in the data directory on the C: drive, use this command:
    cd c:\data
    
  2. In the command prompt, enter the following command to convert the NMEA file to the GPX file:
    gpsbabel -i nmea -f btnmeatrack_2014-05-22_13-35-40.nmea -o gpx -F 2014-05-22_13_35-40.gpx
    

spatialite-gui

spatialite-gui is a GUI tool supporting SpatiaLite. This is lightweight and very useful when you need to quickly perform some queries or just check contents of the SQLite/SpatiaLite database.

To explore spatial or nonspatial tables in the SpatiaLite database, perform these steps:

  1. Start spatialite-gui by double-clicking on its executable file.
  2. Connect to the database that you want to explore by navigating to Files | Connecting an existing SQLite DB or clicking on the corresponding button on the toolbar.
  3. Select the table you want to explore in the table tree on the left-hand side of the spatialite-gui dialog, open its context menu by clicking on the right mouse button, and select the Edit table rows menu entry.
  4. If your table contains spatial data, it is possible to view geometry in different representations. Select the field with the geometry information in the row, open the context menu by clicking the right mouse button and select the BLOB Explore menu entry:
    spatialite-gui

After massive edits, especially when tables were altered or deleted, it is recommended to run VACUUM command to rebuild the database. To do this, perform these steps:

  1. Start spatialite-gui by double-clicking on its executable file.
  2. Connect to the database that you want to explore by navigating to Files | Connecting an existing SQLite DB or clicking on the corresponding button on the toolbar.
  3. Navigate to Files | Optimizing current SQLite DB [VACUUM] or click on the corresponding button on the toolbar.

pgAdmin

pgAdmin is an administration tool and development platform for PostgreSQL databases. It allows you to perform administrative tasks (such as backup and restore), run simple queries as well as develop new databases from scratch.

To create a backup of the database with pgAdmin, follow these steps:

  1. Start pgAdmin by clicking on its desktop shortcut or by finding it in the Start menu.
  2. Create a connection to your database server if it does not exist by navigating to File | Add Server… or clicking on the corresponding button on the toolbar.
  3. Connect to the database server where your database is located by double-clicking on its name in Object Browser on the left-hand side of the pgAdmin window.
  4. Select the database that you want to back up, open its context menu by clicking the right mouse button, and select Backup. A backup settings dialog will be opened, as shown in the following screenshot:
    pgAdmin
  5. Choose a location where your backup will be saved, adjust the backup options according to your needs, and click on the Backup button to start the backup process. The progress will be displayed in the Messages tab.

To restore the database from the backup, perform the following steps:

  1. Start pgAdmin by clicking on its desktop shortcut or by finding it in the Start menu.
  2. Create a connection to your database server if it does not exist by navigating to File | Add Server... or clicking on the corresponding button on the toolbar.
  3. Connect to the database server where you want to restore the backup and double-click on its name in Object Browser on the left-hand side of the pgAdmin window.
  4. Select database that should be restored, open its context menu by clicking the right mouse button, and select Restore. A restore options dialog will be opened, as shown in the following screenshot:
    pgAdmin

    Note

    It is worth mentioning that the pg_restore tool used by pgAdmin to restore cannot create the database that has to be restored. It is necessary to create a new empty database manually and then start the restoration with this freshly created database.

  5. Select the location of the backup file and adjust the restore options according to your needs.

    Tip

    Note that you can restore single table or schema, just click on the Display objects button after selecting the backup file and choose desired objects on the Objects tab.

  6. Click on the Restore button to start restoring. The progress will be displayed in the Messages tab.

How it works…

All of the tools here work on the same file formats as QGIS. This allows for greater flexibility when working by being able to use the best tool at the right time.

There's more…

There are many other different tools that can be useful in various situations, for example, exiv2 can be used to manipulate the EXIF tags of the photos, ImageMagic to process rasters, and so on.