Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Practical GIS

You're reading from  Practical GIS

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781787123328
Pages 428 pages
Edition 1st Edition
Languages

Table of Contents (22) Chapters

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface
Setting Up Your Environment Accessing GIS Data With QGIS Using Vector Data Effectively Creating Digital Maps Exporting Your Data Feeding a PostGIS Database A PostGIS Overview Spatial Analysis in QGIS Spatial Analysis on Steroids - Using PostGIS A Typical GIS Problem Showcasing Your Data Styling Your Data in GeoServer Creating a Web Map Appendix

Querying rasters


As PostGIS has limited raster capabilities compared to the sophisticated algorithms that GRASS GIS has, we have no way to calculate walking distances in our spatial database. However, in PostGIS, we can query raster tables and carry out basic terrain analysis, like calculating aspect. Querying raster layers with points is a surprisingly fast operation in PostGIS, as it can use the bounding boxes of raster tiles for geometry indexing, transform our points to pixel coordinates in the correct tile, and get the corresponding value from the stored binary raster by calculating an offset in bytes. We can use the ST_Value function to query raster data as follows:

    SELECT h.*, ST_Value(r.rast, h.geom) AS elevation
     FROM spatial.vw_semifinalhouses h, spatial.srtm r
     WHERE ST_Intersects(r.rast, h.geom);

The only limitation of ST_Value is that it only accepts single-part points. Therefore, if we stored our houses as multipoint geometries, we need to extract the first geometry...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}