This post outlines the processing of a very high resolution Digital Elevation Model (DEM), the national Swedish DEM at 2 m spatial resolution. A more comprehensive discussion on DEM and how to process elevation data using Karttur’s GeoImagine Framework is covered by the blog Framework project: Digital Elevation Models (DEMs).
Introduction
Processing DEMs all the way from downloading tiles to creating coherent indices and metrics of landscapes, is a typical task for which Karttur’s GeoImagine Framework was built. Once the DEM is imported and organized within the Framework, it is easy to test different algorithms and visualizations. If you have access to some ground data you can also apply the Framework for comparing the results of different algorithms and parameters against ground data, and thus select the most appropriate landscape model.
Metria national 2 m DEM over Sweden
The national DEM in 2 m over Sweden is not freely available. This post assumes that you have obtained the DEM in its original tiles from some other legitimate source.
Process chain
Once you have retrieved the DEM, you need to prepare and import the dataset to the Framework. A tiled dataset, like the Metria 2m DEM over Sweden, must be prepared as a virtual full coverage dataset prior to importing and then retiling into the (customized) projection system that are used for the actual spatial data processing in the Framework. For the Metria 2 m DEM over Sweden, the sequence of processes thus becomes:
- identification of raw tile bounding boxes (optional),
- mosaic raw tiles,
- organize (import into Framework), and
- tiling to the Framework projection system.
Bounding Boxes for raw tiles
Framework process: BBoxTiledRawData
Json command file: 0122_BBoxTiledRawData_metria-DEM.json
## Create vector bounding boxes for the 2 m DEM tiles
### REMOVE TO RUN ### 0122_BBoxTiledRawData_metria-DEM.json
The process BBoxTiledRawData creates bounding boxes for each raw tile. For the Swedish 2 m DEM all the branches of the root directory containing the individual DEM tiles is searched (the parameter getlist is set to oswalk). As the directory tree also contains supplementary (metadata) .tif files, the search is set to exclude files containing the string “density” (the parameter nonpattern is set to density). The reason that the search is set to excluding a particular pattern is that the actual data tiles do not have any distinguishable naming pattern.
Note that the process can take a long time if there are many (thousands) of tiles to loop over. When running this April 2022, the 2 m DEM from Metria is composed of of 73195 tiles. The process generates a single vector data source with all the included tiles. The version of the DEM I had access to in April 2022 does not cover the complete Swedish land mass (see figure below). The no-data holes for large lakes causes further problems when applying the DEM for hydrological modelling.
Mosaic raw tiles
Framework process: MosaicAncillary
Json command file: 0125_MosaicAncillary_metria-DEM.json
## Mosaic DEM ##
### REMOVE TO RUN ### 0125_MosaicAncillary_metria-DEM.json
Downloaded data that are delivered as arbitrary tiles need to be mosaicked together before importing to the Framework. (SMAP, MODIS and Sentinel standard products do not need mosaicking of raw tiles as these datasets either are downloaded in predefined tiling systems or as complete global datasets). The mosaicking must be done as virtual (.vrt) dataset. To actually create a true mosaic of Sweden at 2 m spatial resolution would take a long time and also take up unnecessary much disk space. The process MosaicAncillary does not register the imported (organized in the terminology of the Framework) dataset into the database, that is done in the next step.
Organize (import and register) ancillary dataset
Framework process: OrganizeAncillary
Json command file: 0160_OrganizeAncillary_CopDEM-90m
## Import and register DEM tiles ##
### REMOVE TO RUN ### 0160_Organizeprojsys_metria-DEM.json
With the Copernicus data downloaded, unzipped and mosaicked, the data can be organized for the Framework. For the Copernicus DEM data, the process OrganizeAncillary only imports the virtual mosaic linked to the original (downloaded and unzipped) tiles.
Once you have run the json command, you can check in the Framework database, and you should find that the ancillary schema contains a layer with the compid dem_copdem. Apart from being defined as an individual layer, the dataset is also registered as a product (table: compprod) and a composition (table: compdef):
SELECT * FROM ancillary.layer WHERE compid = 'dem_copdem';
SELECT * FROM ancillary.compprod WHERE compid = 'dem_copdem';
SELECT * FROM ancillary.compdef WHERE compid = 'dem_copdem';
Tiling to Framework projection system
Framework process: TileProjSysRegion
Json command files:
0180_TileProjSysRegion_metria-DEM_10m-mean.json
0180_TileProjSysRegion_metria-DEM_10m-min.json
## tile DEM to 10 m average of 25 cells##
### REMOVE TO RUN ### 0180_TileProjSysRegion_metria-DEM_10m-mean.json
## tile DEM to 10 m minimum of 25 cells##
### REMOVE TO RUN ### 0180_TileProjSysRegion_metria-DEM_10m-min.json
All basic processing in the Framework is done using predefined tiling systems. The process TileAncillaryRegion constructs tiles while also reprojecting the source (ancillary) data to the projection system defined under userproject: system. For the CopDEM data in this example, the data are reprojected and tiled for the ease2n (EASE GRID 2.0 North) projection system.