GIS Crashcourse

Back to SIG GIS Tutorials

Author: Gary Johnson

Date: 2022-04-28

General GIS Info

GIS data is split into two distinct categories:

There are many raster and vector file formats in the GIS field, but we have restricted ourselves to just two:

In GIS terminology, a vector dataset is sometimes called a "feature collection" in that it is a collection of "features". A feature is a pair of a geometry (e.g., point, linestring, polygon) and a set of attributes (key=value pairs like a Clojure map). In general, a feature can have any number of attributes up to the limits of the containing file format. This is what we are doing on Pyregence with the zonal stats Shapefiles.

However, raster data (which we are storing as GeoTIFFs) are just numerical arrays.

You can think of raster data as a 3D cube, in which the x and y dimensions represent space and the z dimension (called the "band") can be used to essentially stack multiple 2D arrays on top of one another.

Sometimes a multi-band raster uses its bands to store different variables on each band. For example, many USFS fire behavior models take an LCP file (raster GIS format) as one of their inputs.

The LCP file is just an 8-band raster, in which each band is one of the following variables:

The other common way that the z axis (band) is used in multi-band rasters is to let it represent the time dimension. A typical example of this would be a 24-band temperature raster, in which each band contains the 2D array of temperature at one hour of a day.

GIS Specifics on Pyrecast/GeoServer

One way that we could reduce the number of GeoTIFFs on our GeoServer machines is to have Chris produce multi-band (time) rasters for the weather variables. Then each forecast would have one raster per variable (e.g., temperature, relative humidity, etc.), and each such raster would have a number of bands equal to the number of hours we display on our time slider.

Unfortunately, we don't have currently have a viable way to actually request a particular band of data from a multi-band raster through WMS calls to GeoServer.

Instead, the alternative (and quite poorly documented) approach that we discovered is to register an entire directory of GeoTIFFs (one single-band raster per timestep) as an "imagemosaic timeseries" layer in GeoServer. This approach (when it works) reduces the layer registration time (since you are only registering directories not every single layer) and the total number of layers on the GeoServer.

Realistically, in order to support the much larger number of layers that Chris wants to add to PyreCast this fire season, we have to either get imagemosaic timeseries registration working, find a hitherto unknown way of requesting a single band from a multiband raster over WMS, or write our own multiband GeoTIFF server.

Web Services

There are four main web services that we use to display GIS data on the web:

1. WMS (Web Mapping Service): Request either a raster or vector layer (or some combination of these) as a singular color image file (e.g., PNG, JPEG). Used mainly by web mapping libraries (e.g., OpenLayers, Leaflet, Mapbox).

2. WMTS (Web Mapping Tile Service): Request either a raster or vector layer (or some combination of these) as cached image tiles (mostly 256x256 pixel size). An improvement over WMS because WMTS tiles can be pre-rendered on the server side and cached on the client size. When using WMTS with GeoServer, GeoWebCache must be enabled.

3. WFS (Web Feature Service): Request a vector layer as a vector GIS file (e.g., Shapefile, GeoJSON).

4. WCS (Web Coverage Service): Request a raster layer as a raster GIS file (e.g., GeoTIFF, AAIGrid).

GeoServer supports all four of these protocols. The PyreCast web app constructs WMTS requests for the majority of the map imagery that we display via Mapbox. There are some layers (currently only the "*Active Fires" layer on the Active Fires tab) that PyreCast grabs using WFS requests. Whereas the WMTS requests simply return PNG images/tiles that are dropped into Mapbox as is, the WFS requests return vector features (i.e., geometries + attributes) that we then manually display on the map via Mapbox's vector layer creation commands.

When to use WMTS vs. WFS

A WFS allows uniform direct access to the features stored on a server. Use a WFS when you want to perform actions such as:

A WMTS allows for uniform rendering access to features stored on a server. Use a WMTS when you want to perform actions such as: