The project code and links, including the xml files are available under GitHub geoimagine-project.
Create region
There is no initial default region that covers Africa south of the Sahara. To create a default region, login as superuser and define the corners of the default region in longitude and latitude. The parent region for Sub-Saharan Africa should be the African continent.
At present you have to create the default region from the setup_processes package. To access the xml file above, either create a direct link to the xml file, or add it to the existing text file linking other xml command files.
Link MODIS tiles
The xml below identifies all MODIS SIN tiles that overlap with the African Sub-Sahara region defined in the xml above. The process LinkDefaultRegionsToMODIS by default identifies all MODIS tiles for all regions. But if you set overwrite = False (the default setting) only default regions that do not have any identified MODIS tiles are tested. The source composition (<srccomp>) defined in the xml is for the shape file with the MODIS tiles as polygons. If your Framework lack the MODIS tiles, you need to setup the regions, including the MODIS tiling system as described in this post.
You can check directly after the script finishes for the MODIS tiles linked to the region africasubsahara. Open the postgreSQL Graphical User Interface (GUI) and the production database, and then type the SQL command:
SELECT * FROM modis.regions where regionid = 'africasubsahara'
The Framework is built in such a way that no user, including the super users, can use default regions for actual data processing. All processing can only be done vis-a-vis regions that are owned by the logged in user. Thus you have to create user regions (called “tracts”) that correspond to the default regions that you created above.
Before downloading and processing any MODIS data you can update the Framework database on MODIS tiles available for download by running the process searchDataPool.
In the example above the MODIS data holdings are updated for 2018 and 2019. If any additional data is found, it will be under the sub-folder /Volumes/”volume”/DataPoolModis/ (where “volume” is the path given in the xml file).
Transfer MDOIS tile to local db
If you identified any additional MODIS tiles in the previous step, you need to add them to the local postgres database. The process ModisSearchToDB will do that:
The process for actually downloading regional MODIS tiles from the DataPool is downloadModisRegionTiles. By default the process only downloads tiles that are not registered as downloaded in the local database. If, ofr some reason, you want to download also tiles registered as already downloaded you set the parameter downloaded to True. If the tile is already in the <dstpath> the process will not download the tile (even if downloaded is set to True), unless <overwrite> is set to True.
In the above example the parameter asscript is set to True (= default, only set for clarity) and you can run the download script (reported when the script ends) from any machine. Just copy the script and change the local paths in the script. Remember that you must convert the shell script file to be executable before you can actually run it:
You need to make sure that your login credentials to the DataPool are correctly given on the machine you are using for the download (as explained in this post).
Register downloaded tiles
If you set the download parameter asscript to True the MODIS tiles are both downloaded and registered in the local database on the fly. By default, however, the download is done via a shell script file and you must register the downloaded tiles by rerunning the process downloadModisRegionTiles.
Alternatively you can run the process CheckMODISRegion that by default checks both for downloaded and exploded tiles. You can turn off the checking of either by setting the parameters checkdownloaded or checkexploded to False. If you set both to False the script will report an error as there is nothing to check.
While the process downloadModisRegionTiles identifies tiles (.hdf) from the database, the process downloadModisRegionTiles searches the folder tree for .hdf files. The former is process is thus faster as it i) retrieves the tiles from the database, and ii) does not have to clean the identified tiles to fit the set timestep.
The downloaded MODIS tiles come as .hdf files. The Framework can access this format, but only as a complete file (not as sequences of smaller buffers), and to processes MODIS data you need to explode (or extract) the bands (or layers) that you wish to use. Which bands to extract from each MODIS product is hardcoded in the postgres database, in the table modis.template. To see which bands to exctrat, and the default folder and layer name, use the postgreSQL GUI, e.g.:
SELECT * FROM modis.template WHERE source = 'MCD43A4v006';
The xml file command below explodes all tiles from the MODIS product MCD34A4 (version 006) over Sub-Saharan Africa fulfilling the period criteria. The default is again that the explosion is done asscript (but I also added it explicitly for clarity in the example below):
If you set the parameter asscript to False, the process ExplodeMODISRegion explodes and registers the layers on the fly, and then also updates the tiles table to state that the tile is exploded (after all requested layers belonging to that tile are exploded). If you do not set the parameter asscript, or set it to False, you have to either rerun the process ExplodeMODISRegion, or run the process CheckMODISRegion.
In the latter case you should set the parameter checkdownload to False. If you leave both checkdownloaded and checkexploded to True, the process will first look for downloaded (.hdf) files, and then look for corresponding layer files (i.e. .tif files). If you set checkdownloaded to False the process will instead search for all .tif files falling inside the region and period defined. If you think that you have unregistered tiles (.hdf) as well as unregistered layers (.hdf) you should run the process twice, with checkdownloaded set to to True the first time and False the second time. It is, however, much faster to rerun the process ExplodeMODISRegion, and if your database and datafile organization is flawless, that is the preferred option.
With the MODIS derived data organized into tiles, you need to convert other data into the same tiling system.
TRMM
The Tropical Rainfall Measurement Mission (TRMM) data is at 0.25 degrees spatial resolution and extends between 50 degrees latitudes. For this project you are going to use the monthly TRMM product that is created using a range of satellite data and supported by ground observed preciptation (product 3B43). The temporal availability of the TRMM 3B43 is from to November 2018.
In a previous post on TRMM the data is both cleaned, filled and masked to include only land. The xml file below tiles the monthly data to all MODIS tiles covered by the region “karttur-africasubsahara”. The spatial resolution of the destinations tiles equals the resolutions of the MODIS product MCD43A4 (463 m)
With the parameter asscript set to True you need to run the shell script fine reported when the process ends. And then rerun the same xml command to register the tiles in the database.
The spatial resolution of the TRMM tiles created from the xml above (463) is artificially high. It will only be used for cell by cell correlation with soil moisture derived from the MODIS product MCD43A4. The original TRMM data is in 0.25 degrees spatial resolution, which approximately translates to 28 km. The xml below creates the same tiles as the xml above, but at a spatial resolution of 27798.78 m. This odd number translates into exactly 40 columns and 40 rows for each MODIS tile. When you later create a mosaic and projects that mosaic back to Geographic coordinates you will see that the data exactly fits the original TRMM.
To compare TRMM with GRACE data wee need to create a third version of the TRMM tiles, in approximately 1 degree resolutions. That translates to a spatial resolution of 111195.12 (or 10 rows and 10 lines for each modis tile). As this tiling reduces the spatial resolution, you should set the parameter resample to average.
You can run all the three tiling processes together, but you must then set the parameter asscript to False and run all tiling on the fly.
<?xml version='1.0' encoding='utf-8'?>
<subsahara>
<userproj userid = 'karttur' projectid = 'karttur-africasubsahara' tractid= 'karttur-africasubsahara' siteid = '*' plotid = '*' system = 'modis'></userproj>
<period startyear = "1998" endyear = "2018" endmonth ='7' endday = '31' timestep='M'></period>
<!-- tile the original (monthly) TRMM data to the region (karttur-africasubsahara).
The TRMM data must be downloaded and organized
If you set the parameter "asscript" to True (= default),
you have to execute the shell script file as reported by the process,
and then rerun the xml with overwrite set to False to add the layers to the database
-->
<process processid = 'tileRegionToModisAncillary' version = '1.3'>
<overwrite>False</overwrite>
<parameters src_defregid = 'trmm' epsg = '6842' xres = '463.313' yres = '463.313' resample='near' asscript='False'></parameters>
<srcpath volume = "Pegasus6"></srcpath>
<dstpath volume = "TILES"></dstpath>
<srccomp>
<trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall" band = "trmm-3b43v7-precip" prefix = "rainfall" suffix = "v7-f-m">
</trmm-3b43v7-precip>
</srccomp>
</process>
<!-- The second process below tiles the same data, but at a spatial resolution of 27798.78 m -->
<process processid = 'tileRegionToModisAncillary' version = '1.3'>
<overwrite>False</overwrite>
<parameters src_defregid = 'trmm' epsg = '6842' xres = '27798.78' yres = '27798.78' resample='near' asscript='False' suffix = 'v7-f-m-30km'></parameters>
<srcpath volume = "Pegasus6"></srcpath>
<dstpath volume = "TILES"></dstpath>
<srccomp>
<trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall" band = "trmm-3b43v7-precip" prefix = "rainfall" suffix = "v7-f-m">
</trmm-3b43v7-precip>
</srccomp>
</process>
<!-- The third process below tiles the same data, but at a spatial resolution of approx 1 deg (111195.12) -->
<process processid = 'tileRegionToModisAncillary' version = '1.3'>
<overwrite>False</overwrite>
<parameters src_defregid = 'trmm' epsg = '6842' xres = '111195.12' yres = '111195.12' resample='average' asscript='False' suffix = 'v7-f-m-1deg'></parameters>
<srcpath volume = "Pegasus6"></srcpath>
<dstpath volume = "TILES"></dstpath>
<srccomp>
<trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall" band = "trmm-3b43v7-precip" prefix = "rainfall" suffix = "v7-f-m">
</trmm-3b43v7-precip>
</srccomp>
</process>
</subsahara>
One of the ideas with the Framework is that processing should not be redundant. For Ancillary time-series data all time-series processing should be done using the original (system:ancillary) rather than the tiled (system:modis or mgrs) data. The TRMM time series analysis should hence be done in system = ancillary and any statistical, trend or model results transferred using tiling (rather than processing at the tile level). The xml below tiles the TRMM time-series data to all tiles included in the default region “africasubsahara” (the region on which the tract “karttur-africasubsahara” is built).
<okadeltaproject>
<userproj userid = 'karttur' projectid = 'karttur-africasubsahara' tractid= 'karttur-africasubsahara' siteid = '*' plotid = '*' system = 'modis'></userproj>
<period startyear = "1998" endyear = "2017" timestep='timespan-A'></period>
<!-- Tile statistical TRMM data to the region (karttur-okadelta)
The TRMM data must be processed
If you set the parameter "asscript" to True (= default),
you have to execute the shell script file as reorted by the processor,
and then rerun the xml with overwrite set to False to add the layers to the database
-->
<process processid = 'tileRegionToModisAncillary' version = '1.3'>
<overwrite>False</overwrite>
<parameters src_defregid = 'trmm' epsg = '6842' xres = '27798.78' yres = '27798.78' resample='near' asscript='N' suffix = 'v7-f-A-30km'></parameters>
<srcpath volume = "karttur3tb"></srcpath>
<dstpath volume = "karttur3tb"></dstpath>
<srccomp>
<avg-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-stats" band = "avg-trmm-3b43v7-precip" prefix = "avg-trmm-3b43v7-precip" suffix = "v7-f-A">
</avg-trmm-3b43v7-precip>
<ols-ic-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ols-ic-trmm-3b43v7-precip" prefix = "ols-ic-trmm-3b43v7-precip" suffix = "v7-f-A">
</ols-ic-trmm-3b43v7-precip>
<ts-ic-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ts-ic-trmm-3b43v7-precip" prefix = "ts-ic-trmm-3b43v7-precip" suffix = "v7-f-A">
</ts-ic-trmm-3b43v7-precip>
<ols-sl-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ols-sl-trmm-3b43v7-precip" prefix = "ols-sl-trmm-3b43v7-precip" suffix = "v7-f-A">
</ols-sl-trmm-3b43v7-precip>
<ts-mdsl-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ts-mdsl-trmm-3b43v7-precip" prefix = "ts-mdsl-trmm-3b43v7-precip" suffix = "v7-f-A">
</ts-mdsl-trmm-3b43v7-precip>
<ts-losl-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ts-losl-trmm-3b43v7-precip" prefix = "ts-losl-trmm-3b43v7-precip" suffix = "v7-f-A">
</ts-losl-trmm-3b43v7-precip>
<ts-hisl-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ts-hisl-trmm-3b43v7-precip" prefix = "ts-hisl-trmm-3b43v7-precip" suffix = "v7-f-A">
</ts-hisl-trmm-3b43v7-precip>
<std-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-stats" band = "std-trmm-3b43v7-precip" prefix = "std-trmm-3b43v7-precip" suffix = "v7-f-A">
</std-trmm-3b43v7-precip>
<ols-rmse-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ols-rmse-trmm-3b43v7-precip" prefix = "ols-rmse-trmm-3b43v7-precip" suffix = "v7-f-A">
</ols-rmse-trmm-3b43v7-precip>
<mk-z-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "mk-z-trmm-3b43v7-precip" prefix = "mk-z-trmm-3b43v7-precip" suffix = "v7-f-A">
</mk-z-trmm-3b43v7-precip>
<ols-r2-trmm-3b43v7-precip source = "trmm" product = "3b43" folder = "rainfall-A-trend" band = "ols-r2-trmm-3b43v7-precip" prefix = "ols-r2-trmm-3b43v7-precip" suffix = "v7-f-A">
</ols-r2-trmm-3b43v7-precip>
<trmm-3b43v7-precip-change source = "trmm" product = "3b43" folder = "rainfall-A-change" band = "trmm-3b43v7-precip-change" prefix = "trmm-3b43v7-precip-change" suffix = "model-v7-f-A">
</trmm-3b43v7-precip-change>
<trmm-3b43v7-precip-delta source = "trmm" product = "3b43" folder = "rainfall-A-change" band = "trmm-3b43v7-precip-delta" prefix = "trmm-3b43v7-precip-delta" suffix = "slope@p-v7-f-A">
</trmm-3b43v7-precip-delta>
</srccomp>
</process>
<!-- This second process is required due to duplicate compids-->
<process processid = 'tileRegionToModisAncillary' version = '1.3'>
<overwrite>False</overwrite>
<parameters src_defregid = 'trmm' epsg = '6842' xres = '27798.78' yres = '27798.78' resample='near' asscript='False'></parameters>
<srcpath volume = "karttur3tb"></srcpath>
<dstpath volume = "karttur3tb"></dstpath>
<srccomp>
<trmm-3b43v7-precip-change source = "trmm" product = "3b43" folder = "rainfall-A-change" band = "trmm-3b43v7-precip-change" prefix = "trmm-3b43v7-precip-change" suffix = "model@p-v7-f-A">
</trmm-3b43v7-precip-change>
</srccomp>
</process>
</okadeltaproject>
SNULLE
GRACE
GRACE animation with TRMM overlay
Assume that the GRACE estimated mm water pillar is primarily related to local rainfall. We are going to test that assumption by cross-correlating the local TRMM rainfall with the local variation in GRACE mm water pillar. But before we do the statistical cross correlation we can create an animation that show both time series in the same movie frame. The basic concept for how to create such an animation is found in the blog post Animation with inset map.
Inthe Framework, the process movieoverlayframeModisRegion creates the map parts of the movie frames, with one base maps and one overlay map. The xml below creates a map with the GRACE mm water pillar as the base map and the TRMM rainfall as the overlay. Both the GRACE and TRMM data must be mosaicked and exported as shown above.