You are previewing QGIS Blueprints.
O'Reilly logo
QGIS Blueprints

Book Description

Develop analytical location-based web applications with QGIS

About This Book

  • Tame geographic information workflows with QGIS blueprints for smart web applications

  • Create geographic web applications using QGIS and free/open source software

  • Blueprints provide real-world applications covering many use cases

  • Who This Book Is For

    This book encompasses relatively experienced GIS developers who have a strong grounding in the fundamentals of GIS development. They will have used QGIS before, but are looking to understand how to develop more complex, layered map applications that expose various data sets, utilize different visualizations, and are consumable (usable) by end users

    What You Will Learn

  • Review geographic information principles and the application of these principles in the QGIS free/open source ecosystem

  • Perform advanced analysis with site selection, hydrologic, and topological networks

  • Build performant web applications by tile caching and generating static assets

  • Provide collaborative editing capabilities for your team or community

  • Develop custom and dynamic analysis and visualization capabilities

  • Select the best components from desktop and web, for your use case

  • Integrate it with social media and crowdsourcing

  • In Detail

    QGIS, the world’s most popular free/open source desktop geographic information system software, enables a wide variety of use cases involving location – previously only available through expensive specialized commercial software. However, designing and executing a multi-tiered project from scratch on this complex ecosystem remains a significant challenge.

    This book starts with a primer on QGIS and closely related data, software, and systems. We’ll guide you through six use-case blueprints for geographic web applications. Each blueprint boils down a complex workflow into steps you can follow to reduce time lost to trial and error.

    By the end of this book readers should be able to build complex layered applications that visualize multiple data sets, employing different types of visualization, and give end users the ability to interact with and manipulate this data for the purpose of analysis.

    Style and approach

    This is a comprehensive guide to the application of QGIS and free/open source software in creating web applications from analysis. Step-by-step blueprints guide the reader through analytical and web development topics and designs.

    Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. QGIS Blueprints
      1. Table of Contents
      2. QGIS Blueprints
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Exploring Places – from Concept to Interface
        1. The software
          1. The development community and dependencies
            1. Data format read/write
            2. Geospatial coordinate transformation
            3. Analysis
            4. Web publishing
          2. Installation
            1. Linux
            2. Mac
            3. Windows
            4. OSGeo-Live
        2. Acquiring data for geospatial applications
          1. Producing geospatial data with georeferencing
            1. Table join
            2. Geocode
            3. Orthorectify
          2. The spatial reference manipulation – making the coordinates line up
            1. Setting CRS
            2. Transformation and projection
        3. Visualizing GIS data
          1. The layer style
          2. Labels
        4. The basemap
          1. Using OpenStreetMap for the basemap data
            1. Avoiding obscurity and confusion
          2. The layer scale dependency
          3. The label conflict
            1. The polygon label conflict resolution
          4. Tile caches
            1. Generating and testing a simple directory-based tile cache structure
            2. Create a layer description file for the TileLayer plugin
        5. Summary
      9. 2. Identifying the Best Places
        1. Vector data – Extract, Transform, and Load
          1. Loading data and establishing the CRS conformity
          2. The extracting (filtering) features
          3. Converting to raster
          4. Doing more at once—working in batch
        2. Raster analysis
          1. Map algebra
          2. Additive modeling
            1. Proximity
              1. Creating a proximity to the easements grid
            2. Slope
            3. Combining the criteria with Map Calculator
            4. Zonal statistics
        3. Publishing the results as a web application
          1. qgis2leaf
        4. Summary
      10. 3. Discovering Physical Relationships
        1. Hydrological modeling
          1. Preparing the data
            1. Filling the grid sinks
            2. Clipping the grid to study the area by mask layer
          2. Modeling the hydrological network based on elevation
          3. Workflow automation with the graphical models
            1. Creating a graphical model
            2. Adding the input parameters
              1. Adding the raster parameter – elevation
              2. Adding the vector parameter – extent
            3. Adding the algorithms
              1. Fill Sinks
              2. Clip raster
              3. Channel network and drainage basins
            4. Running the model
        2. Spatial join for a performant operational layer interaction
          1. The NNJoin plugin
        3. The CartoDB platform
          1. Publishing the data to CartoDB
          2. Preparing a CartoDB SQL Query
            1. Generating the test data
            2. The CartoDB SQL view tab
            3. The QGIS CartoDB plugin
            4. The CartoDB SQL API
        4. Leaflet and an external API: CartoDB SQL
        5. Summary
      11. 4. Finding the Best Way to Get There
        1. Postgres with PostGIS and pgRouting
          1. Installing Postgres/PostGIS/pgRouting
          2. Creating a new Postgres database
          3. Registering the PostGIS and pgRouting extensions
        2. OpenStreetMap data for topology
          1. Downloading the OSM data
          2. Adding the data to the map
          3. Projecting the OSM data
          4. Splitting all the lines at intersections
        3. Database importing and topological relationships
          1. Connecting to the database
          2. Importing into PostGIS with DB Manager
          3. Creating the topological network data
          4. An alternate workflow: topology with osm2po
          5. Using the pgRouting Layer plugin to test
        4. Creating the travel time isochron polygons
          1. Generating the travel time for each road segment
          2. Creating isochron polygons
            1. Converting the travel time lines to points
            2. Selecting the travel time ranges in points and creating convex hulls
        5. Generating the shortest paths for all students
          1. Finding the associated segment for a student location
          2. Calculating the accumulated shortest paths by segment
            1. Flow symbology
        6. Web applications – creating safe corridors
          1. Registering a Twitter account and API access
          2. Setting up the Twitter Tools API
        7. Summary
      12. 5. Demonstrating Change
        1. Leveraging spatial relationships
          1. Gathering the data
            1. Boundaries
            2. Tabular data from American FactFinder
          2. Preparing and exporting the data
            1. The tabular data
              1. Combining it yearly
              2. Updating and removing fields
            2. The boundary data
              1. Calculating the average white population change in each census tract
              2. The spatial join in SpatiaLite
                1. Creating a SpatiaLite database
                2. Importing layers to SpatiaLite
                3. Querying and loading the SpatiaLite layer from the DB Manager
        2. TopoJSON
          1. An example of GeoJSON
          2. An example of TopoJSON
          3. Vector simplification
            1. Simplification methods
              1. Other options
            2. Simplifying for TopoJSON
            3. Simplifying for other outputs
          4. Converting to TopoJSON
            1. Web mapshaper
            2. The command-line tool
        3. The D3 data visualization library
          1. What is D3?
            1. Some fundamentals
              1. Parsing
              2. Graphic elements, SVG, path, and Canvas
              3. Projection
              4. Shape generator
              5. Scales
              6. Binding
              7. Select, Select All, Enter, Return, Exit, Insert, and Append
          2. Animated time series map
            1. The development environment
            2. Code
              1. main.js
            3. Output
        4. Summary
      13. 6. Estimating Unknown Values
        1. Importing the data
          1. Connecting and importing from MySQL in QGIS
          2. Converting to spatial format
            1. The layer/table relations
          3. NetCDF
            1. Viewing NetCDF in QGIS
        2. Interpolated model values
          1. Python for workflow automation
            1. Knowing your environment
          2. Generating the parameter grids for each time period
            1. What this code does
            2. Running a code in Python
            3. Running the printed commands in the Windows command console
              1. The subprocess module
          3. Calculating the vulnerability index
          4. Creating regular points
          5. Sampling the index grid by points
            1. Create SQLite database and import
        3. A dynamic web application – OpenLayers AJAX with Python and SpatiaLite
          1. Server side – CGI in Python
            1. Python CGI development
              1. Starting a CGI hosting
              2. Testing the CGI hosting
              3. Debugging server-side code
            2. Our Python server-side, database-driven code
              1. PySpatiaLite
              2. The Python code for web access to SQLite through JSON
          2. The OpenLayers/jQuery client-side code
            1. Exporting the OpenLayers 3 map using QGIS
            2. Modifying the exported OpenLayers 3 map application
              1. Adding an interactive HTML element
              2. AJAX – the glue between frontend and backend
                1. Adding an AJAX call to the singleclick event handler
                2. Populating and triggering the popup from the callback function
          3. Testing the application
        4. Summary
      14. 7. Mapping for Enterprises and Communities
        1. Google Sheets for data management
          1. Creating a new Google document
          2. Publishing Google Sheets on the Web
          3. Previewing JSON
          4. Parsing the JSON data
            1. Starting up the server
            2. Test parsing with jQuery
          5. Rollout
            1. Assigning permissions to additional users
            2. The editing workflow
            3. The publishing workflow
            4. Viewing the changes in your JSON feed
        2. The cartographic rendering of geospatial data – MBTiles and UTFGrid
          1. OpenStreetMap to SpatiaLite
          2. To tile and use UTFGrid with TileMill
            1. Preparing a basemap from OSM
            2. Preparing the operational layer in TileMill
            3. Exporting MBTiles
              1. Uploading to Mapbox
              2. The MBTiles file
        3. Interacting with Mapbox services
          1. Connecting your local app with a hosted service
            1. The API token
            2. Mapbox.js
              1. Simple UTFGrid modification
              2. Previewing a simple UTFGrid modification
            3. OpenLayers
              1. Code modification
        4. Putting it all together
          1. Parsing the sheets JSON feed
          2. Completing the application
        5. Going further – local MBTiles hosting with TileStream
          1. Setting up a Vagrant virtual Linux instance
          2. Installing Node.js and TileStream
          3. Setting up and starting TileStream
        6. Summary
      15. Index