SAGA-GIS examples from 2018-12 OGTA Training Course.
The example area of interest (AoI) here is Liberia, defined as: * lat_n +9 * lat_s -6 * lon_e -23 * lon_w -3
This is an example of how to use SAGA GIS via saga_cmd (bash cmd used
via python subprocess) to process data. The .shp output(s) are then
displayed using mapnik. Some
alternative display options are enumerated
here.
Project Dir Explaination
The expected directory structure here: (TODO: this might not be essential within these examples)
- PROJECTS
- LIBERIA - Project files for this area
- DATA - information about datasets
- BASEMAP
- BORDERS - Shapes for mapping
- RELIEF- Bathymetry and topography
- OCEAN
- WOD- World Ocean Database
- WOA- World Ocean Atlas
- [OTHER SOURCES] - folders identified by acronyms (optional)
- PRODUCTS - Files created by the following programs:
- IDV - Integrated Data Viewer: synthesis program for many operational datasets and some GIS objects
- ODV - Ocean Data View: ocean station data management,
analysis, display
- COLLECTIONS - data by data type, area or other original selection criteria
- IMAGES - Saved images of graphics
- INTERPOLATIONS - XYZ data triplets exported from ODV “surface mode” AKA grids b/c derived from grid-like interpolations
- SUBSETS - Spreadsheets from larger collections
- TIMESERIES - Data analyses based mainly on data/time, not geographic location
- SAGA - Grids and vector products made by our “workhorse”
public domain GIS program
- AUXILIARY - Saved settings/properties files and similar helper files
- GEOIMAGES - Geo-referenced images, using world files or KML/KMZ for positioning; also TIFF grid rasters (for WMS only)
- GRIDS - grids in Saga format, including template grids
- PROJECTS - special files that contain lists of objects to place in one map, including display properties
- TABLES - tabular data from within shapes, and also created alongside them for display management
- VECTORS - points, lines, contours, polygons, graticules, wind arrows, current arrows; ESRI shapes or Google KML/KMZ
- LIBERIA - Project files for this area
Data Sources:
- World Borders from thematicMapping.org
- World EEZ v10 Marine Regions from
marineRegions.org:
- Claus S., De Hauwere N., Vanhoorne B., Souza Dias F., Oset García P., Schepers L., Hernandez F., and Mees J. (Flanders Marine Institute) (2018). MarineRegions.org. Accessed at http://www.marineregions.org on 2018-12-04.
- Modis Aqua Chl Monthly Anomalies from
GMIS
- gmis mapper url, geotiff, NetCDF, & WMS available
TODO: must download data first (or load from remote within python)
#!/usr/bin/env python
import subprocess
import os.path
class input_file(object):
WORLD_EEZ_POLY = "DATA/BASEMAP/BORDERS/eez/eez_v10.shp"
WORLD_EEZ_LINE = "DATA/BASEMAP/BORDERS/eez/eez_boundaries_v10.shp"
LIBERIA_FRAME_POLY = "PRODUCTS/SAGA/VECTORS/frame_liberia_poly.shp"
LIBERIA_FRAME_LINE = "PRODUCTS/SAGA/VECTORS/frame_liberia_line.shp"
@staticmethod
def list_all():
return [
getattr(input_file, a) for a in dir(input_file)
if not a.startswith('_') and
not callable(getattr(input_file, a))
]
# intermediate data:
LIBERIA_EEZ_LINE = "PRODUCTS/SAGA/VECTORS/liberia_eez.shp"
for infile in input_file.list_all():
if(not os.path.isfile(infile)):
raise ValueError("Missing Input file:\n\t{}".format(infile))
cmd = [
'saga_cmd', 'shapes_lines', 'Line-Polygon Intersection',
'-LINES', input_file.WORLD_EEZ_LINE,
'-POLYGONS', input_file.LIBERIA_FRAME_POLY,
'-INTERSECT', LIBERIA_EEZ_LINE
]
print("running bash command:\n\t{}".format(subprocess.list2cmdline(cmd)))
subprocess.check_output(cmd)
# TODO: how to plot?
# === 1 use mapnik_plot like:
# from assets.py.mapnik_plot import mapnik_plot
# mapnik_plot(LIBERIA_EEZ_LINE)
#
# === 2 use [gdal_rasterize](https://www.gdal.org/gdal_rasterize.html) bash cmd
# ```{bash} gdal_rasterize ...???... ```
TODO:
- compare EEZ & Longhurst Province Biodiversity “health” (as defined by @bbest’s indicies)
- play with saga-py
- use more of chl_a anom [@gmis](http://mcc.jrc.ec.europa.eu/emis/)
- can skip over saving intermediate products in python by using data in RAM (see here).