Book Image

Mastering PostGIS

By : Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz
Book Image

Mastering PostGIS

By: Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz

Overview of this book

PostGIS is open source extension onf PostgreSQL object-relational database system that allows GIS objects to be stored and allows querying for information and location services. The aim of this book is to help you master the functionalities offered by PostGIS- from data creation, analysis and output, to ETL and live edits. The book begins with an overview of the key concepts related to spatial database systems and how it applies to Spatial RMDS. You will learn to load different formats into your Postgres instance, investigate the spatial nature of your raster data, and finally export it using built-in functionalities or 3th party tools for backup or representational purposes. Through the course of this book, you will be presented with many examples on how to interact with the database using JavaScript and Node.js. Sample web-based applications interacting with backend PostGIS will also be presented throughout the book, so you can get comfortable with the modern ways of consuming and modifying your spatial data.
Table of Contents (9 chapters)

Outputting and consuming GeoJSON


GML output may be considered by many as not too user-friendly, as XML in general is supposed to be machine readable, but not necessarily human readable (although once one gets used to it - it is not that scary anymore). Luckily, servers such as GeoServer can output data in GeoJSON. This makes things way easier, not only from the perspective of the user looking at the output, but also when it comes to coding the layers that consume it.

This time we will plug in some earthquake data - we will need the data we imported in Chapter 1, Importing Spatial Data, but this time let's put it into the webgis.earthquakes table.

Note

If you happen to have removed the data from the imported_data schema, you will have to reimport the dataset. Otherwise, you can simply copy the data over with select * into webgis.earthquakes from imported_data.earthquakes_subset_with_geom.

Next, make sure to expose the data as a mastering_postgis:earthquakes layer and we are ready to roll.

Note...