Skip to content

ContextualLoadGridClassBuilder

linaizhong edited this page Nov 13, 2014 · 2 revisions

Creating a contextual layer from gridded data using the GridClassBuilder tool

The layer-ingestion project contains a script named contextual_load_GridClassBuilder.sh which creates a contextual layer from raw .adf gridded data using the GridClassBuilder tool.

This ingestion method should be used when:

  • The dataset contains classes of spatial areas, e.g. reefs, basins and shelves in the "Geomorphology of the Australian seafloor" dataset.

  • it is not feasible to polygonize gridded data due to the size of the dataset.

  • The layer id (numeric)

  • The short name for the layer

  • The display name of the layer

  • The path to the raw adf header file for the layer

  • The path to the classes mapping file (described below)

export LAYER_ID=666
export LAYER_SHORT_NAME=newlayer
export LAYER_DISPLAY_NAME="Display name for new layer"
export ADF_HEADER_FILE=/data/ala/data/layers/raw/hdr.adf
export CLASSES_MAPPING_FILE=/data/ala/data/layers/raw/newlayer_classes.txt

The contextual_load_GridClassBuilder.sh script does the following things:

  1. Uses gdalwarp to convert the raw adf data to bil, reprojecting to WGS84.
  2. Converts the bil data to diva format using the Bil2Diva tool.
  3. Processes the diva data using the GridClassesBuilder tool. Note that this tool expects a copy of the classes mapping file to be in the same directory as the diva data. The script will copy the classes mapping file to this location. See below for a more detailed explanation of what the GridClassesBuilder does. The GridClassesBuilder creates a diva dataset called polygons.grd/gri/prj, and an sld legend file named polygons.sld. This data needs to be ingestion into geoserver
  4. Converts the polygons diva dataset generated by GridClassesBuilder into bil using the Diva2Bil tool
  5. Generates a geotiff from the bil data produced in the previous step using gdal_translate
  6. Creates database entries for the layer using the ContextualFromGridDatabaseLoader. Note that this tool creates two fields table entries for the layer - one for the classes, and one for the individual objects.
  7. Creates the layer in geoserver using the GeotiffGeoserverLoader.

NOTE: You may wish to edit the fields table entries generated as part of this process. See ContextualLayerLoadProcess#3._Edit_and_or_add_fields_table_entries

The classes mapping file

The classes mapping file is a simple mapping of the numeric class ids from the raw dataset to the name of the class. Each line should have the format class id = class name. Here is an example:

0=Basin
1=Abyssal plain/deep ocean floor
2=Trench/trough
3=Ridge
4=Knoll/abyssal hills/hills/mountains/peak
5=Slope
6=Terrace
7=Canyon
8=Apron/fan
9=Deep/hole/valley
10=Pinnacle
11=Shelf
12=Sandwave/sandbank
13=Reef
14=Saddle
15=Plateau
16=Seamount/guyot
17=Sill
18=Bank/shoals
19=Rise
20=Escarpment

The GridClassBuilder tool

The GridClassBuilder tool reads the supplied classes mapping file. It then creates a set of files for each class. These files contain the data that would otherwise be stored in the "objects" database table (see Object creation). Instead, this data is read off disk which is why this ingestion method is appropriate for particularly large datasets.

The generated diva dataset contains numeric values for individual polygons instead of for classes. This is done to allow individual polygons to be selected in the web portal and rendered with consistent performance.

Clone this wiki locally