Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

Karttur's GeoImagine Framework:
System setup & tiling

Thomas Gumbricht bio photo By Thomas Gumbricht

In the Framework a system refers to a projection with predefined tiles that can be used for processing spatiotemporal datasets. This post first introduces the concept of a system and outlines the default system, and then explains how to create a custom system.

Introduction

Under the hood, almost all geospatial processing in Karttur’s GeoImagine Framework operates on tiles - regular grids of raster data. To work with the Framework the user must have a pre-defined region (called tract) defined in a project. The tract can for instance be a continent, a country or a district within a country. To create a tract the user must associate it with a predefined default region. The predefined default regions are added when you setup the Framework, and include for instance all the world’s countries. When the Framework is set up, each default region is linked to the predefined tiles of the different projection systems used in the Framework. Thus for instance does the predefined region of the country Spain (es) link to 5 MODIS SIN grid tiles (Figure 1). Including the marine territory of Spain, additional two (2) tiles are linked. Spain is a country that spans two continents - Africa and Europe. The Framework contains separate default regions for the African and European parts of Spain, including both for the terrestrial and terrestrial+marine territories, also illustrated in figure 1.

image image image image
MODIS SIN grid tiling system for the default region Spain; upper left: global terrestrial territories, upper right: global terrestrial + marine territories, lower left: European terrestrial territories, lower rigth: African terrestrial + marine territories.

Prerequisites

To run the tiling processes and produce the illustration in Fig. 1 you must have installed Karttur’s GeoImagine Framework.

Tiling system

Karttur’s GeoImagine Framework includes 5 default tiling systems, each associated with a different projection:

  • MODIS SIN grid
  • EASE 2 north
  • EASE 2 south
  • EASE 2 tropical
  • MGRS

The five different systems have different objectives. MODIS SIN grid is for moderate to coarse resolution (100 m and coarser) global data, and the only consistent global projection. The three EASE 2 systems together cover the globe, and are preferred over MODIS SIN Grid if the data is not truly global. Also the EASE 2 grid data is intended for coarse resolution data. MGRS is the system for fine scaled data, and has a much finer tiling system.

In addition to the above tiling systems, also the Landsat World Resource System (WRS) is included, but rather as a scene location system, used only for retrieving and pre-processing Landsat satellite imagery.

Finally it is possible to define custom systems. These can be arbitrary defined but must have an accepted EPSG code in order for the Framework to translate (reproject) spatial data into the system.

Setup of tiling systems

Each tiling system is setup as a schema in the Framework postgres database. The core tables for defining the system as such (not its spatial data content) include the tables tilecoords (e.g. modis.tilecoords) and regions (e.g. modis.regions).

The table tilecoords defines all the tiles belonging to the projection system. In the projection system itself, the tiles are defined from 4 coordinates (minx, miny, maxx and maxy). Converted to geographic coordinates (longitude, latitude) the corners must be defined using separate longitude and latitude pairs.

All table data is defined when running the <span class”‘module’>setup_db.setup_db_main.py</span> as outlined in the post Set up the database (setup_db) or by using postgres backup restore as described in the post Database backup and restore.

MODIS

The tile coordinates of the MODIS system are added to the database either by running the setup_processes.setup_processes_main.py with the alternative MODIS set to True (see the post Setup processes Part 2 Setup regions, or by using postgres backup restore as descibed in the post Database backup and restore.

The MODIS tiling system contains 36 horizontal tile (htile) columns and 18 vertical tile (vtile) rows. A large portion of these tiles, however, falls outside the Earthly domain. And for many applications with MODIS data, only tiles covering land (or continents excluding small islands) are of interest. To facilitate the use of the MODIS tiling system, the following default regions are added to the postgres database table modis.regions as part of db_setup (in the json parameter file modis_tile_regions_v090_sql.json</file>):

  • global
  • land
  • continent

These regions are required for adding further MODIS regions using the process LinkDefaultRegionTiles. The json parameter file regions-modtiles_v090.json loops over the default regions (including all versions of Spain above) and links the regions ot the MODIS tiling. You can also add all the links between default regions and the MODIS tiles using the Framework process InsertTableCsv. If you set the parameters:

  • "schema": "modis"
  • "table": "regions"

the script will automatically search for the csv backup file

“DISKPATH”/dbdump/geoimagine/modis/regions/csv-geoimagine-modis-regions_YYYY-MM-DD.csv

and INSERT all the records found in that file.

DefineCustomSystem

With the process DefineCustomSystem you can define a new projection system including tiles. It will allow you to utilize the full potential of Karttur’s GeoImagine Framework for any region. In contrast to most other processes, DefineCustomSystem is only accessible from the package setup_processes.

A custom system is defined using the following parameters:

  • systemid [a system identifier]
  • epsg [the system epsg code]
  • minx [the system minimum x coordinate]
  • minx [the system minimum y coordinate]
  • maxx [the system maximum x coordinate]
  • maxy [the system maximum y coordinate]
  • xtiles [nr of columns spanning from minimum to macximum x]
  • ytiles [nr of rows spanning from minimum to macximum y]

Schemas and tables

Each projection system requires that the Framework postgres database have schema with the same name (= systemid) as the system itself. The schema must then contains the following tables:

  • tilecoords
  • regions
  • compdef
  • compprod
  • layer
  • mask

The system table INSERT sql uses a predefined json command file that must be under the path ./systemdoc/system-setup_sql.json directly under the process_setup:

EASE GRID 2 north

As an example, the json command file for creating the EASE GRID 2 North (ease2n) custom system projection is available under the Hide/Show button.