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

Defining custom projections

Map projections stump just about everybody at some point in their GIS career, if not more often. If you're lucky, you just stick to the common ones that are known by everyone and your life is simple. Sometimes though, for a particular location or a custom map, you just need something a little different that isn't in the already vast QGIS projections database. (Often, these are also referred to as Coordinate Reference System (CRS) or Spatial Reference System (SRS).)

I'm not going to cover what the difference is between a Projection, Projected Coordinate System, and a Coordinate system. From a practical perspective in QGIS, you can pick the one that matches your data or your intended output. There's lots of little caveats that come with this, but a book or class is a much better place to get a handle on it.

Getting ready

For this recipe, we'll be using a custom graticule, a grid of lines every 10 degrees (10d_graticule.json.geojson), and the Natural Earth 1:10 million coastline (ne_10m_coastline.shp).

How to do it…

  1. Determine what projection your data is currently in. In this case, we're starting with EPSG:4236, which is also known as Lat/Lon WGS84.
  2. Determine what projection you want to make a map in. In this example, we'll be making an Oblique Stereographic projection centered on Ireland.
  3. Search the existing QGIS projection list for a match or similar projection. If you open the Projection dialog and type Stereographic, this is a good start.
  4. If you find a similar projection and just want to customize it, highlight the proj4 string and copy the information. NAD83(CSRS) / Prince Edward Isl. Stereographic (NAD83) is a similar enough projection.

    Tip

    If you don't find anything in the QGIS projection database, search the Web for a proj4 string for the projection that you want to use. Sometimes, you'll find Projection WKT. With a little work, you can figure out which proj4 slot each of the WKT parameters corresponds to using the documentation at https://github.com/OSGeo/proj.4/wiki/GenParms. A good place to research projections is provided at the end of this recipe.

  5. Under Settings, open the Custom CRS option.
  6. Click on the + symbol to add a new definition.
  7. Put in a name and paste in your projection string, modifying it in this case with coordinates that center on Ireland. Change the values for the lat_0 and lon_0 parameters to match the following example. This particular type of projection only takes one reference point. For projections with multiple standard parallels and meridians, you will see the number after the underscore increment:
    +proj=sterea +lat_0=53.5 +lon_0=-7.8 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

    The following screenshot shows what the screen will look like:

    How to do it…
  8. Now, click on another projection in the list of custom projections. There's currently a quirk where if you don't toggle off to another projection, then it doesn't save when you click on OK.
  9. Now, go to the map, open the projection manager and apply your new projection with OTF on to check whether it's right. You'll find your new projection in the third section, User Defined Coordinate Systems:
    How to do it…

    The following screenshot shows the projection:

    How to do it…

How it works…

Projection information (in this case, a proj4 string) encodes the parameters that are needed by the computer to pick the correct math formula (projection type) and variables (various parameters, such as parallels and the center line) to convert the data into the desired flat map from whatever it currently is. This library of information includes approximations for the shape of the earth and differing manners to squash this into a flat visual.

You can really alter most of the parameters to change your map appearance, but generally, stick to known definitions so that your map matches other maps that are made the same way.

There's more…

QGIS only allows forward/backward transformation projections. Cartographic forward-only projections (for example, Natural Earth, Winkel Tripel (III), and Van der Grinten) aren't in the projection list currently; this is because these reprojections are not a pure math formula, but an approximate mapping from one to the other, and the inverse doesn't always exist. You can get around this by reprojecting your data with the ogr2ogr and gdal_transform command line to the desired projection, and then loading it into QGIS with Projection-on-the-fly disabled. While the proj4 strings exist for these projections, QGIS will reject them if you try to enter them.

Tip

If you disable Projection-on-the-fly, make sure that all layers are in the same projection; otherwise, they won't line up. Also, perform all analysis steps before converting to a projection that is intended for cartography, as the units of measurement may become messy.

Geometries that cross the outer edge of projections don't always cut off nicely. You will often see this as an unexpected polygon band across your map. The easiest thing to do in this case is to remove data that is outside your intended mapping region. You can use a clip function or simply select what you want to keep and Save Selection As a new layer.

There are other common projection description formats (prj, WKT, and proj4) out there. Luckily, several websites help you translate. There are a couple of good websites to look up the existing Proj4 style projection information available at http://spatialreference.org and http://epsg.io.

See also